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