-
Notifications
You must be signed in to change notification settings - Fork 166
LG-12577 Allow active profile to sign in to non-biometric SP #10211
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
11 commits
Select commit
Hold shift + click to select a range
2b289cc
user has active profile and non biometric request will not redirect
theabrad a9691ea
add user#active_legacy_profile
theabrad 067afe2
add changelog
theabrad 571f5fe
fix tests and logic
theabrad ecbb827
add check for verified attributes in test
theabrad a9fec7e
created PendingProfilePolicy
theabrad a38c598
remove user#active_legacy_profile
theabrad aec27ef
use PendingProfilePolicy in oidc authorize controller
theabrad 26c0505
Merge branch 'main' of github.com:18F/identity-idp into abrad-lg-1257…
theabrad faa3bf1
useable -> usable
theabrad 4a86a79
add test for vots in auth controller
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
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| class PendingProfilePolicy | ||
| def initialize(user:, resolved_authn_context_result:, biometric_comparison_requested:) | ||
| @user = user | ||
| @resolved_authn_context_result = resolved_authn_context_result | ||
| @biometric_comparison_requested = biometric_comparison_requested | ||
| end | ||
|
|
||
| def user_has_usable_pending_profile? | ||
| if biometric_comparison_requested? | ||
| pending_biometric_profile? | ||
| else | ||
| pending_legacy_profile? || fraud_review_pending? | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| attr_reader :user, :resolved_authn_context_result, :biometric_comparison_requested | ||
|
|
||
| def active_biometric_profile? | ||
| user.active_profile&.idv_level == 'unsupervised_with_selfie' | ||
| end | ||
|
|
||
| def pending_biometric_profile? | ||
| user.pending_profile&.idv_level == 'unsupervised_with_selfie' | ||
| end | ||
|
|
||
| def biometric_comparison_requested? | ||
| return false if !FeatureManagement.idv_allow_selfie_check? | ||
| resolved_authn_context_result.biometric_comparison? || biometric_comparison_requested | ||
| end | ||
|
|
||
| def pending_legacy_profile? | ||
| user.pending_profile.present? && user.pending_profile&.idv_level != 'unsupervised_with_selfie' | ||
| end | ||
|
|
||
| def fraud_review_pending? | ||
| user.fraud_review_pending? | ||
| end | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe PendingProfilePolicy do | ||
| let(:user) { create(:user) } | ||
| let(:resolved_authn_context_result) do | ||
| AuthnContextResolver.new( | ||
| service_provider: nil, | ||
| vtr: vtr, | ||
| acr_values: acr_values, | ||
| ).resolve | ||
| end | ||
| let(:biometric_comparison_requested) { nil } | ||
| let(:vtr) { nil } | ||
| let(:acr_values) { nil } | ||
|
|
||
| subject(:policy) do | ||
| described_class.new( | ||
| user: user, | ||
| resolved_authn_context_result: resolved_authn_context_result, | ||
| biometric_comparison_requested: biometric_comparison_requested, | ||
| ) | ||
| end | ||
|
|
||
| describe '#user_has_usable_pending_profile?' do | ||
| context 'has an active non-biometric profile and biometric comparison is requested' do | ||
| let(:idv_level) { :unsupervised_with_selfie } | ||
| before do | ||
| create(:profile, :active, :verified, idv_level: :legacy_unsupervised, user: user) | ||
| create(:profile, :verify_by_mail_pending, idv_level: idv_level, user: user) | ||
| allow(FeatureManagement).to receive(:idv_allow_selfie_check?).and_return(true) | ||
| end | ||
|
|
||
| context 'with resolved authn context result' do | ||
| let(:vtr) { ['C2.Pb'] } | ||
|
|
||
| it 'has a usable pending profile' do | ||
| expect(policy.user_has_usable_pending_profile?).to eq(true) | ||
| end | ||
| end | ||
|
|
||
| context 'with biometric_comparison_requested param set to true' do | ||
| let(:biometric_comparison_requested) { true } | ||
| let(:acr_values) { Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF } | ||
|
|
||
| it 'has a usable pending profile' do | ||
| expect(policy.user_has_usable_pending_profile?).to eq(true) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context 'no biometric comparison is requested' do | ||
| let(:idv_level) { :legacy_unsupervised } | ||
| let(:vtr) { ['C2'] } | ||
| context 'user has pending profile' do | ||
| before do | ||
| create(:profile, :verify_by_mail_pending, idv_level: idv_level, user: user) | ||
| end | ||
|
|
||
| it { expect(policy.user_has_usable_pending_profile?).to eq(true) } | ||
| end | ||
|
|
||
| context 'user has an active profile' do | ||
| before do | ||
| create(:profile, :active, :verified, idv_level: idv_level, user: user) | ||
| end | ||
|
|
||
| it { expect(policy.user_has_usable_pending_profile?).to eq(false) } | ||
| end | ||
|
|
||
| context 'user has active legacy profile with a pending fraud biometric profile' do | ||
| before do | ||
| create(:profile, :active, :verified, idv_level: idv_level, user: user) | ||
| create(:profile, :fraud_review_pending, idv_level: :unsupervised_with_selfie, user: user) | ||
| end | ||
|
|
||
| it { expect(policy.user_has_usable_pending_profile?).to eq(true) } | ||
| end | ||
| end | ||
| end | ||
| end |
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.
Uh oh!
There was an error while loading. Please reload this page.