class Rack::OAuth2::Server::OAuthRequest

Wraps Rack::Request to expose Basic and OAuth authentication credentials.

Constants

AUTHORIZATION_KEYS

Public Instance Methods

authorization() click to toggle source

Returns authorization header.

# File lib/rack/oauth2/server.rb, line 555
def authorization
  @authorization ||= AUTHORIZATION_KEYS.inject(nil) { |auth, key| auth || @env[key] }
end
basic?() click to toggle source

True if authentication scheme is Basic.

# File lib/rack/oauth2/server.rb, line 565
def basic?
  authorization[/^basic/i] if authorization
end
credentials() click to toggle source

If Basic auth, returns username/password, if OAuth, returns access token.

# File lib/rack/oauth2/server.rb, line 571
def credentials
  basic? ? authorization.gsub(/\n/, "").split[1].unpack("m*").first.split(/:/, 2) :
  oauth? ? authorization.gsub(/\n/, "").split[1] : nil
end
oauth?() click to toggle source

True if authentication scheme is OAuth.

# File lib/rack/oauth2/server.rb, line 560
def oauth?
  authorization[/^oauth/i] if authorization
end