Class: Warden::Strategies::Doorkeeper
- Inherits:
-
Base
- Object
- Base
- Warden::Strategies::Doorkeeper
- Defined in:
- lib/warden/strategies/doorkeeper.rb
Constant Summary collapse
- VERSION =
"0.3.0"
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #authenticate! ⇒ Object
-
#config ⇒ Object
Returns the configuration data for the default user scope.
-
#initialize(env, scope = nil) ⇒ Doorkeeper
constructor
A new instance of Doorkeeper.
- #valid? ⇒ Boolean
Constructor Details
#initialize(env, scope = nil) ⇒ Doorkeeper
8 9 10 11 12 |
# File 'lib/warden/strategies/doorkeeper.rb', line 8 def initialize(env, scope=nil) super @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/warden/strategies/doorkeeper.rb', line 6 def scope @scope end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/warden/strategies/doorkeeper.rb', line 6 def token @token end |
Instance Method Details
#authenticate! ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/warden/strategies/doorkeeper.rb', line 19 def authenticate! user = User.where(id: @token.resource_owner_id).first if user success!(user) else fail!("No such user") end end |
#config ⇒ Object
Returns the configuration data for the default user scope.
29 30 31 32 33 34 35 36 |
# File 'lib/warden/strategies/doorkeeper.rb', line 29 def config scopes = env["warden"].config[:scope_defaults] if scopes && scopes[:user] scopes[:user][:config] else {} end end |
#valid? ⇒ Boolean
14 15 16 17 |
# File 'lib/warden/strategies/doorkeeper.rb', line 14 def valid? @token = ::Doorkeeper::OAuth::Token.authenticate(request, *Doorkeeper.configuration.access_token_methods) @token && @token.accessible? && @token.acceptable?(@scope) end |