Class: SignIn::TokenParamsValidator

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/services/sign_in/token_params_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params:) ⇒ TokenParamsValidator

Returns a new instance of TokenParamsValidator.

[View source] [View on GitHub]

40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/services/sign_in/token_params_validator.rb', line 40

def initialize(params:)
  @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]
end

Instance Attribute Details

#actor_tokenObject (readonly)

Returns the value of attribute actor_token.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def actor_token
  @actor_token
end

#actor_token_typeObject (readonly)

Returns the value of attribute actor_token_type.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def actor_token_type
  @actor_token_type
end

#assertionObject (readonly)

Returns the value of attribute assertion.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def assertion
  @assertion
end

#client_assertionObject (readonly)

Returns the value of attribute client_assertion.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def client_assertion
  @client_assertion
end

#client_assertion_typeObject (readonly)

Returns the value of attribute client_assertion_type.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def client_assertion_type
  @client_assertion_type
end

#client_idObject (readonly)

Returns the value of attribute client_id.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def client_id
  @client_id
end

#codeObject (readonly)

Returns the value of attribute code.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def code
  @code
end

#code_verifierObject (readonly)

Returns the value of attribute code_verifier.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def code_verifier
  @code_verifier
end

#grant_typeObject (readonly)

Returns the value of attribute grant_type.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def grant_type
  @grant_type
end

#subject_tokenObject (readonly)

Returns the value of attribute subject_token.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def subject_token
  @subject_token
end

#subject_token_typeObject (readonly)

Returns the value of attribute subject_token_type.

[View on GitHub]

7
8
9
# File 'app/services/sign_in/token_params_validator.rb', line 7

def subject_token_type
  @subject_token_type
end

Instance Method Details

#authorization_code_grant?Boolean (private)

Returns:

  • (Boolean)
[View source] [View on GitHub]

64
65
66
# File 'app/services/sign_in/token_params_validator.rb', line 64

def authorization_code_grant?
  grant_type == Constants::Auth::AUTH_CODE_GRANT
end

#client_assertion_type_present?Boolean (private)

Returns:

  • (Boolean)
[View source] [View on GitHub]

76
77
78
# File 'app/services/sign_in/token_params_validator.rb', line 76

def client_assertion_type_present?
  client_assertion_type.present?
end

#jwt_bearer_grant?Boolean (private)

Returns:

  • (Boolean)
[View source] [View on GitHub]

68
69
70
# File 'app/services/sign_in/token_params_validator.rb', line 68

def jwt_bearer_grant?
  grant_type == Constants::Auth::JWT_BEARER_GRANT
end

#log_error_and_raise(message) ⇒ Object (private)

[View source] [View on GitHub]

80
81
82
83
# File 'app/services/sign_in/token_params_validator.rb', line 80

def log_error_and_raise(message)
  Rails.logger.error('[SignIn][TokenParamsValidator] error', { errors: message })
  raise Errors::MalformedParamsError.new(message:)
end

#performObject

[View source] [View on GitHub]

54
55
56
57
58
59
60
# File 'app/services/sign_in/token_params_validator.rb', line 54

def perform
  validate!
rescue ActiveModel::ValidationError => e
  log_error_and_raise(e.model.errors.full_messages.to_sentence)
rescue => e
  log_error_and_raise(e.message)
end

#token_exchange_grant?Boolean (private)

Returns:

  • (Boolean)
[View source] [View on GitHub]

72
73
74
# File 'app/services/sign_in/token_params_validator.rb', line 72

def token_exchange_grant?
  grant_type == Constants::Auth::TOKEN_EXCHANGE_GRANT
end