-
Notifications
You must be signed in to change notification settings - Fork 166
LG-12150 add vot to the identity token #10142
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
875d5da
add changelog
theabrad 63d448f
add vot function to identity token
theabrad 6c77af2
id_token_builder sends correct acr and vtr values
theabrad eddf90f
add changelog
theabrad f0a6e23
fix identity vot and acr names
theabrad 61f70ff
acr value only has IAL values within
theabrad b2ce75d
hide vot behind feature flag
theabrad 402811e
store vtm in identity config
theabrad 5b407af
fixup with config
theabrad dddb63c
add check to not allow vtm if vot is nil
theabrad 905756c
Merge branch 'main' of github.com:18F/identity-idp into abrad-lg-1215…
theabrad 39e208e
revamp acr method to return correct ial acr values
theabrad 0b1ce29
restart code climate
theabrad 89293b5
trying code climate again
theabrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,12 +38,14 @@ def jwt_payload | |
| def id_token_claims | ||
| { | ||
| acr: acr, | ||
| vot: (vot if sp_requests_vot?), | ||
| vtm: (IdentityConfig.store.vtm_url if sp_requests_vot?), | ||
| nonce: identity.nonce, | ||
| aud: identity.service_provider, | ||
| jti: SecureRandom.urlsafe_base64, | ||
| at_hash: hash_token(identity.access_token), | ||
| c_hash: hash_token(code), | ||
| } | ||
| }.compact | ||
| end | ||
|
|
||
| def timestamp_claims | ||
|
|
@@ -55,24 +57,43 @@ def timestamp_claims | |
| end | ||
|
|
||
| def acr | ||
| ial = identity.ial | ||
| case ial | ||
| when Idp::Constants::IAL_MAX then determine_ial_max_acr | ||
| when Idp::Constants::IAL1 then Saml::Idp::Constants::IAL1_AUTHN_CONTEXT_CLASSREF | ||
| when Idp::Constants::IAL2 then Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF | ||
| return nil unless identity.acr_values.present? | ||
|
|
||
| if resolved_authn_context_result.ialmax? | ||
| determine_ial_max_acr.name | ||
| elsif resolved_authn_context_result.identity_proofing? | ||
| Vot::LegacyComponentValues::IAL2.name | ||
| else | ||
| raise "Unknown ial #{ial}" | ||
| Vot::LegacyComponentValues::IAL1.name | ||
| end | ||
| end | ||
|
|
||
| def sp_requests_vot? | ||
|
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. We probably also want to add a |
||
| return false unless identity.vtr.present? | ||
| IdentityConfig.store.use_vot_in_sp_requests | ||
| end | ||
|
|
||
| def vot | ||
| return nil unless identity.vtr.present? | ||
| resolved_authn_context_result.component_values.map(&:name).join('.') | ||
| end | ||
|
|
||
| def determine_ial_max_acr | ||
| if identity.user.identity_verified? | ||
| Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF | ||
| Vot::LegacyComponentValues::IAL2 | ||
| else | ||
| Saml::Idp::Constants::IAL1_AUTHN_CONTEXT_CLASSREF | ||
| Vot::LegacyComponentValues::IAL1 | ||
| end | ||
| end | ||
|
|
||
| def resolved_authn_context_result | ||
| @resolved_authn_context_result ||= AuthnContextResolver.new( | ||
| service_provider: identity.service_provider_record, | ||
| vtr: [identity.vtr], | ||
| acr_values: identity.acr_values, | ||
| ).resolve | ||
| end | ||
|
|
||
| def expires | ||
| now.to_i + ttl | ||
| end | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we only return a single ACR value. I'm not sure if we want to start returning the full list because I am not sure how SPs will respond to that.
I believe the previous implementation of responding with the ACR value for the identity assurance level is probably the way to go here to ensure backwards compadibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we could probably remove all the IAL computation in my previous comment if we dressed up this method like so:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And since this didn't stack up like I expected, this is the "previous comment" I am referring to: #10142 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way we:
ial1orial2correctly in the IALMAX caseial1orial2even if the SP requestsloa1orloa3or if the SP makes noialrelated requestial1orial2ACR values even if we introduce new ACR values or change names