Class: PrxAuth::Rails::Token
- Inherits:
-
Object
- Object
- PrxAuth::Rails::Token
- Defined in:
- lib/prx_auth/rails/token.rb
Instance Method Summary collapse
- #authorized?(resource, namespace = nil, scope = nil) ⇒ Boolean
- #authorized_account_ids(scope) ⇒ Object
- #empty_resources? ⇒ Boolean
- #except(*resources) ⇒ Object
- #except!(*resources) ⇒ Object
- #globally_authorized?(namespace, scope = nil) ⇒ Boolean
-
#initialize(token_data) ⇒ Token
constructor
A new instance of Token.
- #resources(namespace = nil, scope = nil) ⇒ Object
- #scopes ⇒ Object
- #user_id ⇒ Object
Constructor Details
#initialize(token_data) ⇒ Token
Returns a new instance of Token.
4 5 6 7 |
# File 'lib/prx_auth/rails/token.rb', line 4 def initialize(token_data) @token_data = token_data @namespace = PrxAuth::Rails.configuration.namespace end |
Instance Method Details
#authorized?(resource, namespace = nil, scope = nil) ⇒ Boolean
9 10 11 12 |
# File 'lib/prx_auth/rails/token.rb', line 9 def (resource, namespace = nil, scope = nil) namespace, scope = @namespace, namespace if scope.nil? && !namespace.nil? @token_data.(resource, namespace, scope) end |
#authorized_account_ids(scope) ⇒ Object
32 33 34 |
# File 'lib/prx_auth/rails/token.rb', line 32 def (scope) @token_data.(scope) end |
#empty_resources? ⇒ Boolean
45 46 47 |
# File 'lib/prx_auth/rails/token.rb', line 45 def empty_resources? @token_data.empty_resources? end |
#except(*resources) ⇒ Object
41 42 43 |
# File 'lib/prx_auth/rails/token.rb', line 41 def except(*resources) dup.except!(*resources) end |
#except!(*resources) ⇒ Object
36 37 38 39 |
# File 'lib/prx_auth/rails/token.rb', line 36 def except!(*resources) @token_data = @token_data.except(*resources) self end |
#globally_authorized?(namespace, scope = nil) ⇒ Boolean
14 15 16 17 |
# File 'lib/prx_auth/rails/token.rb', line 14 def (namespace, scope = nil) namespace, scope = @namespace, namespace if scope.nil? @token_data.(namespace, scope) end |
#resources(namespace = nil, scope = nil) ⇒ Object
19 20 21 22 |
# File 'lib/prx_auth/rails/token.rb', line 19 def resources(namespace = nil, scope = nil) namespace, scope = @namespace, namespace if scope.nil? && !namespace.nil? @token_data.resources(namespace, scope) end |
#scopes ⇒ Object
24 25 26 |
# File 'lib/prx_auth/rails/token.rb', line 24 def scopes @token_data.scopes end |
#user_id ⇒ Object
28 29 30 |
# File 'lib/prx_auth/rails/token.rb', line 28 def user_id @token_data.user_id end |