Class: Rack::PrxAuth::TokenData
- Inherits:
-
Object
- Object
- Rack::PrxAuth::TokenData
- Defined in:
- lib/rack/prx_auth/token_data.rb
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
-
#initialize(attrs = {}) ⇒ TokenData
constructor
A new instance of TokenData.
- #user_id ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ TokenData
Returns a new instance of TokenData.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rack/prx_auth/token_data.rb', line 6 def initialize(attrs = {}) @attributes = attrs if attrs['aur'] = unpack_aur(attrs['aur']).freeze else = {}.freeze end if attrs['scope'] @scopes = attrs['scope'].split(' ').freeze else @scopes = [].freeze end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/rack/prx_auth/token_data.rb', line 4 def attributes @attributes end |
#authorized_resources ⇒ Object (readonly)
Returns the value of attribute authorized_resources.
4 5 6 |
# File 'lib/rack/prx_auth/token_data.rb', line 4 def end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
4 5 6 |
# File 'lib/rack/prx_auth/token_data.rb', line 4 def scopes @scopes end |
Instance Method Details
#authorized?(resource, scope = nil) ⇒ Boolean
24 25 26 27 28 |
# File 'lib/rack/prx_auth/token_data.rb', line 24 def (resource, scope=nil) if auth = [resource.to_s] scope.nil? || (scopes + auth.split(' ')).include?(scope.to_s) end end |
#user_id ⇒ Object
20 21 22 |
# File 'lib/rack/prx_auth/token_data.rb', line 20 def user_id @attributes['sub'] end |