Class: Doorkeeper::Server
- Inherits:
-
Object
- Object
- Doorkeeper::Server
- Defined in:
- lib/doorkeeper/server.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Instance Method Summary collapse
- #authorization_request(strategy) ⇒ Object
- #client ⇒ Object
- #client_via_uid ⇒ Object
- #credentials ⇒ Object
- #current_refresh_token ⇒ Object
- #current_resource_owner ⇒ Object
- #grant ⇒ Object
-
#initialize(context = nil) ⇒ Server
constructor
A new instance of Server.
-
#parameters ⇒ Object
TODO: context should be the request.
-
#resource_owner ⇒ Object
TODO: Use configuration and evaluate proper context on block.
- #token_request(strategy) ⇒ Object
Constructor Details
#initialize(context = nil) ⇒ Server
Returns a new instance of Server.
5 6 7 |
# File 'lib/doorkeeper/server.rb', line 5 def initialize(context = nil) @context = context end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
3 4 5 |
# File 'lib/doorkeeper/server.rb', line 3 def context @context end |
Instance Method Details
#authorization_request(strategy) ⇒ Object
9 10 11 12 |
# File 'lib/doorkeeper/server.rb', line 9 def (strategy) klass = Request. strategy klass.build self end |
#client ⇒ Object
24 25 26 |
# File 'lib/doorkeeper/server.rb', line 24 def client @client ||= OAuth::Client.authenticate(credentials) end |
#client_via_uid ⇒ Object
28 29 30 |
# File 'lib/doorkeeper/server.rb', line 28 def client_via_uid @client_via_uid ||= OAuth::Client.find(parameters[:client_id]) end |
#credentials ⇒ Object
49 50 51 52 |
# File 'lib/doorkeeper/server.rb', line 49 def credentials methods = Doorkeeper.configuration.client_credentials_methods @credentials ||= OAuth::Client::Credentials.from_request(context.request, *methods) end |
#current_refresh_token ⇒ Object
36 37 38 |
# File 'lib/doorkeeper/server.rb', line 36 def current_refresh_token Doorkeeper::AccessToken.by_refresh_token(parameters[:refresh_token]) end |
#current_resource_owner ⇒ Object
32 33 34 |
# File 'lib/doorkeeper/server.rb', line 32 def current_resource_owner context.send :current_resource_owner end |
#grant ⇒ Object
40 41 42 |
# File 'lib/doorkeeper/server.rb', line 40 def grant Doorkeeper::AccessGrant.authenticate(parameters[:code]) end |
#parameters ⇒ Object
TODO: context should be the request
20 21 22 |
# File 'lib/doorkeeper/server.rb', line 20 def parameters context.request.parameters end |
#resource_owner ⇒ Object
TODO: Use configuration and evaluate proper context on block
45 46 47 |
# File 'lib/doorkeeper/server.rb', line 45 def resource_owner context.send :resource_owner_from_credentials end |
#token_request(strategy) ⇒ Object
14 15 16 17 |
# File 'lib/doorkeeper/server.rb', line 14 def token_request(strategy) klass = Request.token_strategy strategy klass.build self end |