Class: Rack::OAuth2::Server::OAuthRequest
- Inherits:
-
Request
- Object
- Request
- Rack::OAuth2::Server::OAuthRequest
- Defined in:
- lib/rack/oauth2/server.rb
Overview
Wraps Rack::Request to expose Basic and OAuth authentication credentials.
Constant Summary collapse
- AUTHORIZATION_KEYS =
%w{HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION X_HTTP_AUTHORIZATION}
Instance Method Summary collapse
-
#authorization ⇒ Object
Returns authorization header.
-
#basic? ⇒ Boolean
True if authentication scheme is Basic.
-
#credentials ⇒ Object
If Basic auth, returns username/password, if OAuth, returns access token.
-
#oauth? ⇒ Boolean
True if authentication scheme is OAuth.
Instance Method Details
#authorization ⇒ Object
Returns authorization header.
430 431 432 |
# File 'lib/rack/oauth2/server.rb', line 430 def @authorization ||= AUTHORIZATION_KEYS.inject(nil) { |auth, key| auth || @env[key] } end |
#basic? ⇒ Boolean
True if authentication scheme is Basic.
440 441 442 |
# File 'lib/rack/oauth2/server.rb', line 440 def basic? [/^basic/i] if end |
#credentials ⇒ Object
If Basic auth, returns username/password, if OAuth, returns access token.
446 447 448 449 |
# File 'lib/rack/oauth2/server.rb', line 446 def credentials basic? ? .gsub(/\n/, "").split[1].unpack("m*").first.split(/:/, 2) : oauth? ? .gsub(/\n/, "").split[1] : nil end |
#oauth? ⇒ Boolean
True if authentication scheme is OAuth.
435 436 437 |
# File 'lib/rack/oauth2/server.rb', line 435 def oauth? [/^oauth/i] if end |