Class: Simple::OAuth2::Strategies::Base
- Inherits:
-
Object
- Object
- Simple::OAuth2::Strategies::Base
- Defined in:
- lib/simple_oauth2/strategies/base.rb
Overview
Base Strategies class. Contains common functionality for all the descendants
Direct Known Subclasses
AuthorizationCode, ClientCredentials, Code, Password, RefreshToken, Token
Class Method Summary collapse
-
.authenticate_access_grant(request) ⇒ Object
Authenticates Access Grant from the request.
-
.authenticate_client(request) ⇒ Object
Authenticates Client from the request.
-
.authenticate_resource_owner(client, request) ⇒ Object
Authenticates Resource Owner from the request.
-
.authorization_verify_client!(request, response) ⇒ Object
Authorization endpoint, check client and redirect_uri for exact matching verifier.
-
.expose_to_bearer_token(token) ⇒ Rack::OAuth2::AccessToken::Bearer
Exposes token object to Bearer token.
-
.token_verify_client!(request) ⇒ Object
Token endpoint, check client for exact matching verifier.
Class Method Details
.authenticate_access_grant(request) ⇒ Object
Authenticates Access Grant from the request
24 25 26 |
# File 'lib/simple_oauth2/strategies/base.rb', line 24 def authenticate_access_grant(request) config.access_grant_class.by_token(request.code) end |
.authenticate_client(request) ⇒ Object
Authenticates Client from the request
10 11 12 |
# File 'lib/simple_oauth2/strategies/base.rb', line 10 def authenticate_client(request) config.client_class.by_key(request.client_id) end |
.authenticate_resource_owner(client, request) ⇒ Object
Authenticates Resource Owner from the request
15 16 17 18 19 20 21 |
# File 'lib/simple_oauth2/strategies/base.rb', line 15 def authenticate_resource_owner(client, request) config.resource_owner_class.oauth_authenticate( client, request.params['username'], request.params['password'] ) end |
.authorization_verify_client!(request, response) ⇒ Object
Authorization endpoint, check client and redirect_uri for exact matching verifier
45 46 47 48 49 |
# File 'lib/simple_oauth2/strategies/base.rb', line 45 def (request, response) client = authenticate_client(request) || request.bad_request! response.redirect_uri = request.verify_redirect_uri!(client.redirect_uri) client end |
.expose_to_bearer_token(token) ⇒ Rack::OAuth2::AccessToken::Bearer
Exposes token object to Bearer token.
33 34 35 |
# File 'lib/simple_oauth2/strategies/base.rb', line 33 def expose_to_bearer_token(token) Rack::OAuth2::AccessToken::Bearer.new(token.to_bearer_token) end |
.token_verify_client!(request) ⇒ Object
Token endpoint, check client for exact matching verifier
38 39 40 41 42 |
# File 'lib/simple_oauth2/strategies/base.rb', line 38 def token_verify_client!(request) client = authenticate_client(request) || request.invalid_client! client.secret == request.client_secret || request.invalid_client! client end |