Class: SignIn::TokenResponseGenerator
- Inherits:
-
Object
- Object
- SignIn::TokenResponseGenerator
- Defined in:
- app/services/sign_in/token_response_generator.rb
Instance Attribute Summary collapse
-
#actor_token ⇒ Object
readonly
Returns the value of attribute actor_token.
-
#actor_token_type ⇒ Object
readonly
Returns the value of attribute actor_token_type.
-
#assertion ⇒ Object
readonly
Returns the value of attribute assertion.
-
#client_assertion ⇒ Object
readonly
Returns the value of attribute client_assertion.
-
#client_assertion_type ⇒ Object
readonly
Returns the value of attribute client_assertion_type.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#code_verifier ⇒ Object
readonly
Returns the value of attribute code_verifier.
-
#cookies ⇒ Object
readonly
Returns the value of attribute cookies.
-
#grant_type ⇒ Object
readonly
Returns the value of attribute grant_type.
-
#subject_token ⇒ Object
readonly
Returns the value of attribute subject_token.
-
#subject_token_type ⇒ Object
readonly
Returns the value of attribute subject_token_type.
Instance Method Summary collapse
- #generate_client_tokens ⇒ Object private
- #generate_service_account_token ⇒ Object private
- #generate_token_exchange_response ⇒ Object private
-
#initialize(params:, cookies:) ⇒ TokenResponseGenerator
constructor
A new instance of TokenResponseGenerator.
- #perform ⇒ Object
- #serialized_service_account_token(access_token:) ⇒ Object private
- #sign_in_logger ⇒ Object private
Constructor Details
#initialize(params:, cookies:) ⇒ TokenResponseGenerator
Returns a new instance of TokenResponseGenerator.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/sign_in/token_response_generator.rb', line 8 def initialize(params:, cookies:) @grant_type = params[:grant_type] @code = params[:code] @code_verifier = params[:code_verifier] @client_assertion = params[:client_assertion] @client_assertion_type = params[:client_assertion_type] @assertion = params[:assertion] @subject_token = params[:subject_token] @subject_token_type = params[:subject_token_type] @actor_token = params[:actor_token] @actor_token_type = params[:actor_token_type] @client_id = params[:client_id] @cookies = end |
Instance Attribute Details
#actor_token ⇒ Object (readonly)
Returns the value of attribute actor_token.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def actor_token @actor_token end |
#actor_token_type ⇒ Object (readonly)
Returns the value of attribute actor_token_type.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def actor_token_type @actor_token_type end |
#assertion ⇒ Object (readonly)
Returns the value of attribute assertion.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def assertion @assertion end |
#client_assertion ⇒ Object (readonly)
Returns the value of attribute client_assertion.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def client_assertion @client_assertion end |
#client_assertion_type ⇒ Object (readonly)
Returns the value of attribute client_assertion_type.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def client_assertion_type @client_assertion_type end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def client_id @client_id end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def code @code end |
#code_verifier ⇒ Object (readonly)
Returns the value of attribute code_verifier.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def code_verifier @code_verifier end |
#cookies ⇒ Object (readonly)
Returns the value of attribute cookies.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def @cookies end |
#grant_type ⇒ Object (readonly)
Returns the value of attribute grant_type.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def grant_type @grant_type end |
#subject_token ⇒ Object (readonly)
Returns the value of attribute subject_token.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def subject_token @subject_token end |
#subject_token_type ⇒ Object (readonly)
Returns the value of attribute subject_token_type.
5 6 7 |
# File 'app/services/sign_in/token_response_generator.rb', line 5 def subject_token_type @subject_token_type end |
Instance Method Details
#generate_client_tokens ⇒ Object (private)
38 39 40 41 42 43 44 45 46 |
# File 'app/services/sign_in/token_response_generator.rb', line 38 def generate_client_tokens validated_credential = CodeValidator.new(code:, code_verifier:, client_assertion:, client_assertion_type:).perform session_container = SessionCreator.new(validated_credential:).perform sign_in_logger.info('session created', session_container.access_token.to_s) TokenSerializer.new(session_container:, cookies:).perform end |
#generate_service_account_token ⇒ Object (private)
48 49 50 51 52 53 54 55 |
# File 'app/services/sign_in/token_response_generator.rb', line 48 def generate_service_account_token service_account_access_token = AssertionValidator.new(assertion:).perform sign_in_logger.info('generated service account token', service_account_access_token.to_s) encoded_access_token = ServiceAccountAccessTokenJwtEncoder.new(service_account_access_token:).perform serialized_service_account_token(access_token: encoded_access_token) end |
#generate_token_exchange_response ⇒ Object (private)
57 58 59 60 61 62 63 64 |
# File 'app/services/sign_in/token_response_generator.rb', line 57 def generate_token_exchange_response exchanged_container = TokenExchanger.new(subject_token:, subject_token_type:, actor_token:, actor_token_type:, client_id:).perform sign_in_logger.info('token exchanged', exchanged_container.access_token.to_s) TokenSerializer.new(session_container: exchanged_container, cookies:).perform end |
#perform ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/sign_in/token_response_generator.rb', line 23 def perform case grant_type when Constants::Auth::AUTH_CODE_GRANT generate_client_tokens when Constants::Auth::JWT_BEARER_GRANT generate_service_account_token when Constants::Auth::TOKEN_EXCHANGE_GRANT generate_token_exchange_response else raise Errors::MalformedParamsError.new(message: 'Grant type is not valid') end end |
#serialized_service_account_token(access_token:) ⇒ Object (private)
70 71 72 73 74 75 76 |
# File 'app/services/sign_in/token_response_generator.rb', line 70 def serialized_service_account_token(access_token:) { data: { access_token: } } end |