Class: Rack::PrxAuth::TokenData
- Inherits:
-
Object
- Object
- Rack::PrxAuth::TokenData
- Defined in:
- lib/rack/prx_auth/token_data.rb
Constant Summary collapse
- WILDCARD_RESOURCE_NAME =
'*'
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#authorized_resources ⇒ Object
readonly
Returns the value of attribute authorized_resources.
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
Instance Method Summary collapse
- #authorized?(resource, scope = nil) ⇒ Boolean
- #globally_authorized?(scope) ⇒ Boolean
-
#initialize(attrs = {}) ⇒ TokenData
constructor
A new instance of TokenData.
- #user_id ⇒ Object
Constructor Details
permalink #initialize(attrs = {}) ⇒ TokenData
Returns a new instance of TokenData.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rack/prx_auth/token_data.rb', line 8 def initialize(attrs = {}) @attributes = attrs if attrs['aur'] @authorized_resources = unpack_aur(attrs['aur']).freeze else @authorized_resources = {}.freeze end if attrs['scope'] @scopes = attrs['scope'].split(' ').freeze else @scopes = [].freeze end end |
Instance Attribute Details
permalink #attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/rack/prx_auth/token_data.rb', line 6 def attributes @attributes end |
permalink #authorized_resources ⇒ Object (readonly)
Returns the value of attribute authorized_resources.
6 7 8 |
# File 'lib/rack/prx_auth/token_data.rb', line 6 def @authorized_resources end |
permalink #scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
6 7 8 |
# File 'lib/rack/prx_auth/token_data.rb', line 6 def scopes @scopes end |
Instance Method Details
permalink #authorized?(resource, scope = nil) ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/rack/prx_auth/token_data.rb', line 26 def (resource, scope=nil) if resource == WILDCARD_RESOURCE_NAME (scope) elsif scope.nil? (resource, scope) else (resource, scope) || (scope) end end |
permalink #globally_authorized?(scope) ⇒ Boolean
36 37 38 39 40 |
# File 'lib/rack/prx_auth/token_data.rb', line 36 def (scope) raise ArgumentError if scope.nil? (WILDCARD_RESOURCE_NAME, scope) end |
permalink #user_id ⇒ Object
[View source]
22 23 24 |
# File 'lib/rack/prx_auth/token_data.rb', line 22 def user_id @attributes['sub'] end |