Class: Stormpath::Rails::AccountFromAccessToken::StormpathAccountResolution

Inherits:
Object
  • Object
show all
Defined in:
app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ StormpathAccountResolution

Returns a new instance of StormpathAccountResolution.



7
8
9
10
11
# File 'app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb', line 7

def initialize(access_token)
  @access_token = access_token
  @application = Client.application
  validate_jwt_is_access_token
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



5
6
7
# File 'app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb', line 5

def access_token
  @access_token
end

#applicationObject (readonly)

Returns the value of attribute application.



5
6
7
# File 'app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb', line 5

def application
  @application
end

Instance Method Details

#accountObject



13
14
15
# File 'app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb', line 13

def 
  Stormpath::Oauth::VerifyAccessToken.new(application).verify(access_token).
end

#jwt_dataObject



21
22
23
# File 'app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb', line 21

def jwt_data
  @jwt_data ||= JWT.decode(access_token, ENV['STORMPATH_API_KEY_SECRET'])
end

#validate_jwt_is_access_tokenObject



17
18
19
# File 'app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb', line 17

def validate_jwt_is_access_token
  raise AuthenticationWithRefreshTokenAttemptError if jwt_data.second['stt'] != 'access'
end