Class: PrxAuth::Rails::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/prx_auth/rails/token.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/prx_auth/rails/token.rb', line 9

def authorized?(resource, namespace=nil, scope=nil)
  namespace, scope = @namespace, namespace if scope.nil? && !namespace.nil?
  @token_data.authorized?(resource, namespace, scope)
end

#globally_authorized?(namespace, scope = nil) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/prx_auth/rails/token.rb', line 14

def globally_authorized?(namespace, scope=nil)
  namespace, scope = @namespace, namespace if scope.nil?
  @token_data.globally_authorized?(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

#scopesObject



24
25
26
# File 'lib/prx_auth/rails/token.rb', line 24

def scopes
  @token_data.scopes
end

#user_idObject



28
29
30
# File 'lib/prx_auth/rails/token.rb', line 28

def user_id
  @token_data.user_id
end