Class: OAuth2::Provider::Rack::AuthorizationCodeRequest
- Inherits:
-
Object
- Object
- OAuth2::Provider::Rack::AuthorizationCodeRequest
- Defined in:
- lib/oauth2/provider/rack/authorization_code_request.rb
Instance Method Summary collapse
- #client ⇒ Object
- #client_id ⇒ Object
- #deny! ⇒ Object
- #grant!(resource_owner = nil, authorization_expires_at = nil) ⇒ Object
- #grant_existing!(resource_owner = nil) ⇒ Object
-
#initialize(params) ⇒ AuthorizationCodeRequest
constructor
A new instance of AuthorizationCodeRequest.
- #invalid_scope! ⇒ Object
- #redirect_uri ⇒ Object
- #redirect_uri_valid? ⇒ Boolean
- #scope ⇒ Object
Constructor Details
#initialize(params) ⇒ AuthorizationCodeRequest
Returns a new instance of AuthorizationCodeRequest.
3 4 5 6 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 3 def initialize(params) @params = params validate! end |
Instance Method Details
#client ⇒ Object
38 39 40 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 38 def client @client ||= OAuth2::Provider.client_class.from_param(client_id) end |
#client_id ⇒ Object
34 35 36 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 34 def client_id @params['client_id'] end |
#deny! ⇒ Object
26 27 28 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 26 def deny! throw_response Responses.redirect_with_error('access_denied', redirect_uri) end |
#grant!(resource_owner = nil, authorization_expires_at = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 8 def grant!(resource_owner = nil, = nil) grant = client..create!( :resource_owner => resource_owner, :client => client, :scope => scope, :expires_at => ) code = grant..create! :redirect_uri => redirect_uri throw_response Responses.redirect_with_code(code.code, redirect_uri) end |
#grant_existing!(resource_owner = nil) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 19 def grant_existing!(resource_owner = nil) if existing = OAuth2::Provider..allowing(client, resource_owner, scope).first code = existing..create! :redirect_uri => redirect_uri throw_response Responses.redirect_with_code(code.code, redirect_uri) end end |
#invalid_scope! ⇒ Object
30 31 32 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 30 def invalid_scope! throw_response Responses.redirect_with_error('invalid_scope', redirect_uri) end |
#redirect_uri ⇒ Object
42 43 44 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 42 def redirect_uri @params['redirect_uri'] end |
#redirect_uri_valid? ⇒ Boolean
46 47 48 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 46 def redirect_uri_valid? client && client.allow_redirection?(redirect_uri) end |
#scope ⇒ Object
50 51 52 |
# File 'lib/oauth2/provider/rack/authorization_code_request.rb', line 50 def scope @params['scope'] end |