You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
asciinema.org/app/strategies/api_token_strategy.rb

23 lines
381 B
Ruby

class ApiTokenStrategy < ::Warden::Strategies::Base
def valid?
auth.provided? && auth.basic? && auth.credentials
end
def authenticate!
user = User.for_api_token(auth.credentials.last)
user.nil? ? fail!("Invalid auth token") : success!(user)
end
def store?
false
end
private
def auth
@auth ||= Rack::Auth::Basic::Request.new(env)
end
end