-
Notifications
You must be signed in to change notification settings - Fork 166
LG-12190 Store vtr and acr_values in sp_session #10004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a00798f
13b294b
7acb2ae
a2e0b38
764d74f
6eff3d3
01742af
dcb2fd2
37ef21e
15faa79
1cb5ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ class OpenidConnectAuthorizeForm | |
| ATTRS = [ | ||
| :unauthorized_scope, | ||
| :acr_values, | ||
| :vtr, | ||
| :scope, | ||
| :verified_within, | ||
| :biometric_comparison_required, | ||
|
|
@@ -37,7 +38,7 @@ class OpenidConnectAuthorizeForm | |
| RANDOM_VALUE_MINIMUM_LENGTH = 22 | ||
| MINIMUM_REPROOF_VERIFIED_WITHIN_DAYS = 30 | ||
|
|
||
| validates :acr_values, presence: true | ||
| validates :acr_values, presence: true, if: ->(form) { form.vtr.empty? } | ||
| validates :client_id, presence: true | ||
| validates :redirect_uri, presence: true | ||
| validates :scope, presence: true | ||
|
|
@@ -49,6 +50,7 @@ class OpenidConnectAuthorizeForm | |
| validates :code_challenge_method, inclusion: { in: %w[S256] }, if: :code_challenge | ||
|
|
||
| validate :validate_acr_values | ||
| validate :validate_vtr | ||
| validate :validate_client_id | ||
| validate :validate_scope | ||
| validate :validate_unauthorized_scope | ||
|
|
@@ -59,6 +61,7 @@ class OpenidConnectAuthorizeForm | |
|
|
||
| def initialize(params) | ||
| @acr_values = parse_to_values(params[:acr_values], Saml::Idp::Constants::VALID_AUTHN_CONTEXTS) | ||
| @vtr = parse_vtr(params[:vtr]) | ||
| SIMPLE_ATTRS.each { |key| instance_variable_set(:"@#{key}", params[key]) } | ||
| @prompt ||= 'select_account' | ||
| @scope = parse_to_values(params[:scope], scopes) | ||
|
|
@@ -119,15 +122,27 @@ def ial_context | |
| end | ||
|
|
||
| def ial | ||
| Saml::Idp::Constants::AUTHN_CONTEXT_CLASSREF_TO_IAL[ial_values.sort.max] | ||
| if parsed_vector_of_trust&.identity_proofing? | ||
| 2 | ||
| elsif parsed_vector_of_trust.present? | ||
| 1 | ||
| else | ||
| Saml::Idp::Constants::AUTHN_CONTEXT_CLASSREF_TO_IAL[ial_values.sort.max] | ||
| end | ||
| end | ||
|
|
||
| def aal_values | ||
| acr_values.filter { |acr| acr.include?('aal') } | ||
| end | ||
|
|
||
| def aal | ||
| Saml::Idp::Constants::AUTHN_CONTEXT_CLASSREF_TO_AAL[requested_aal_value] | ||
| if parsed_vector_of_trust&.aal2? | ||
| 2 | ||
| elsif parsed_vector_of_trust.present? | ||
| 1 | ||
| else | ||
| Saml::Idp::Constants::AUTHN_CONTEXT_CLASSREF_TO_AAL[requested_aal_value] | ||
| end | ||
| end | ||
|
|
||
| def requested_aal_value | ||
|
|
@@ -163,7 +178,18 @@ def parse_to_values(param_value, possible_values) | |
| param_value.split(' ').compact & possible_values | ||
| end | ||
|
|
||
| def parse_vtr(param_value) | ||
| return if !IdentityConfig.store.use_vot_in_sp_requests | ||
| return [] if param_value.blank? | ||
|
|
||
| JSON.parse(param_value) | ||
| rescue JSON::ParserError | ||
| nil | ||
| end | ||
|
|
||
| def validate_acr_values | ||
| return if vtr.present? | ||
|
|
||
| if acr_values.empty? | ||
| errors.add( | ||
| :acr_values, t('openid_connect.authorization.errors.no_valid_acr_values'), | ||
|
|
@@ -177,6 +203,15 @@ def validate_acr_values | |
| end | ||
| end | ||
|
|
||
| def validate_vtr | ||
| return if vtr.blank? | ||
| return if parsed_vector_of_trust.present? | ||
| errors.add( | ||
| :vtr, t('openid_connect.authorization.errors.no_valid_vtr'), | ||
| type: :no_valid_vtr | ||
| ) | ||
| end | ||
|
|
||
| # This checks that the SP matches something in the database | ||
| # OpenidConnect::AuthorizationController#check_sp_active checks that it's currently active | ||
| def validate_client_id | ||
|
|
@@ -246,6 +281,7 @@ def extra_analytics_attributes | |
| redirect_uri: result_uri, | ||
| scope: scope&.sort&.join(' '), | ||
| acr_values: acr_values&.sort&.join(' '), | ||
| vtr: vtr, | ||
|
jmhooper marked this conversation as resolved.
|
||
| unauthorized_scope: @unauthorized_scope, | ||
| code_digest: code ? Digest::SHA256.hexdigest(code) : nil, | ||
| code_challenge_present: code_challenge.present?, | ||
|
|
@@ -275,6 +311,19 @@ def scopes | |
| OpenidConnectAttributeScoper::VALID_IAL1_SCOPES | ||
| end | ||
|
|
||
| def parsed_vector_of_trust | ||
| return @parsed_vector_of_trust if defined?(@parsed_vector_of_trust) | ||
| return @parsed_vector_of_trust = nil if vtr.blank? | ||
|
|
||
| @parsed_vector_of_trust = begin | ||
| if vtr.is_a?(Array) && !vtr.empty? | ||
| Vot::Parser.new(vector_of_trust: vtr.first).parse | ||
| end | ||
| rescue Vot::Parser::ParseException | ||
| nil | ||
|
Comment on lines
+322
to
+323
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would we want to catch this exception and add an error for it? or no
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I would like to find a more direct and elegant way of doing it. The trick with this getting reliably re-evaluated with |
||
| end | ||
| end | ||
|
|
||
| def validate_privileges | ||
| if (ial2_requested? && !ial_context.ial2_service_provider?) || | ||
| (ial_context.ialmax_requested? && | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.