Class: CASino::AuthTokenValidationService
- Inherits:
-
Object
- Object
- CASino::AuthTokenValidationService
- Includes:
- AuthenticationProcessor
- Defined in:
- app/services/casino/auth_token_validation_service.rb
Constant Summary collapse
- AUTH_TOKEN_SIGNERS_GLOB =
Rails.root.join('config/auth_token_signers/*.pem').freeze
Instance Attribute Summary collapse
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token, signature) ⇒ AuthTokenValidationService
constructor
A new instance of AuthTokenValidationService.
- #token_data ⇒ Object
- #user_data ⇒ Object
- #validation_result ⇒ Object
Methods included from AuthenticationProcessor
#authenticators, #load_user_data, #validate_login_credentials
Constructor Details
#initialize(token, signature) ⇒ AuthTokenValidationService
Returns a new instance of AuthTokenValidationService.
8 9 10 11 |
# File 'app/services/casino/auth_token_validation_service.rb', line 8 def initialize(token, signature) @token = token @signature = signature end |
Instance Attribute Details
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
6 7 8 |
# File 'app/services/casino/auth_token_validation_service.rb', line 6 def signature @signature end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'app/services/casino/auth_token_validation_service.rb', line 6 def token @token end |
Instance Method Details
#token_data ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/services/casino/auth_token_validation_service.rb', line 31 def token_data begin JSON.parse(token).symbolize_keys rescue JSON::ParserError {} end end |
#user_data ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/casino/auth_token_validation_service.rb', line 18 def user_data return @user_data unless @user_data.nil? return nil unless signature_valid? return nil unless ticket_valid? @user_data = load_user_data(token_data[:authenticator], token_data[:username]).tap do |user| if user.nil? Rails.logger.warn("Could not load user '#{token_data[:authenticator]}'/'#{token_data[:username]}'") else Rails.logger.info("User '#{token_data[:authenticator]}'/'#{token_data[:username]}' successfully identified through auth token.") end end end |
#validation_result ⇒ Object
13 14 15 16 |
# File 'app/services/casino/auth_token_validation_service.rb', line 13 def validation_result return nil unless user_data { authenticator: token_data[:authenticator], user_data: user_data } end |