class Rack::Request
Public Instance Methods
auth()
click to toggle source
# File lib/rack/auth.rb, line 39 def auth return @auth if @auth return nil if @env["HTTP_AUTHORIZATION"].to_s.empty? type, token = @env["HTTP_AUTHORIZATION"].split(" ", 2).map(&:strip) type = type.strip.downcase.to_sym raise TokenValidityError, "Invalid token type." unless AuthHandlers::TOKENS.include? type raise TokenValidityError, "Authorization data cannot have a zero length." if token.empty? args = case type when :bearer, :mac then { "token" => token } when :basic then Hash[["username","password"].zip(Base64.decode64(token).split(":"))] end @auth ||= AuthHandlers[type].call(*args.values) || args end
authenticated!()
click to toggle source
# File lib/rack/auth.rb, line 61 def authenticated! raise TokenPresenceError, "No valid token provided." if auth.nil? auth end
authenticated?()
click to toggle source
# File lib/rack/auth.rb, line 57 def authenticated? !auth.nil? end