Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/forms/openid_connect_authorize_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ class OpenidConnectAuthorizeForm
state
].freeze

ATTRS = [:unauthorized_scope, :acr_values, :scope, :verified_within, *SIMPLE_ATTRS].freeze
ATTRS = [
:unauthorized_scope,
:acr_values,
:scope,
:verified_within,
:biometric_comparison_required,
*SIMPLE_ATTRS,
].freeze

AALS_BY_PRIORITY = [Saml::Idp::Constants::AAL2_HSPD12_AUTHN_CONTEXT_CLASSREF,
Saml::Idp::Constants::AAL3_HSPD12_AUTHN_CONTEXT_CLASSREF,
Saml::Idp::Constants::AAL2_PHISHING_RESISTANT_AUTHN_CONTEXT_CLASSREF,
Expand Down Expand Up @@ -55,6 +63,7 @@ def initialize(params)
@prompt ||= 'select_account'
@scope = parse_to_values(params[:scope], scopes)
@unauthorized_scope = check_for_unauthorized_scope(params)
@biometric_comparison_required = params[:biometric_comparison_required].to_s == 'true'

if verified_within_allowed?
@duration_parser = DurationParser.new(params[:verified_within])
Expand Down Expand Up @@ -130,6 +139,10 @@ def requested_aal_value
:ial2_or_greater?,
:ial2_requested?

def biometric_comparison_required?
@biometric_comparison_required
end

private

attr_reader :identity, :success
Expand Down
4 changes: 4 additions & 0 deletions app/models/federated_protocols/oidc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def requested_attributes
OpenidConnectAttributeScoper.new(request.scope).requested_attributes
end

def biometric_comparison_required?
request.biometric_comparison_required?
end

def service_provider
request.service_provider
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/federated_protocols/saml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def service_provider
current_service_provider
end

def biometric_comparison_required?
false
end

private

attr_reader :request
Expand Down
6 changes: 4 additions & 2 deletions app/models/service_provider_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class ServiceProviderRequest
# WARNING - Modification of these params requires particular care
# since these objects are serialized to/from Redis and may be present
# upon deployment
attr_accessor :uuid, :issuer, :url, :ial, :aal, :requested_attributes
attr_accessor :uuid, :issuer, :url, :ial, :aal, :requested_attributes,
:biometric_comparison_required

def initialize(
uuid: nil,
Expand All @@ -11,14 +12,15 @@ def initialize(
ial: nil,
aal: nil,
requested_attributes: [],
biometric_comparison_required: false # rubocop:disable Lint/UnusedMethodArgument
biometric_comparison_required: false
)
@uuid = uuid
@issuer = issuer
@url = url
@ial = ial
@aal = aal
@requested_attributes = requested_attributes&.map(&:to_s)
@biometric_comparison_required = biometric_comparison_required
end

def ==(other)
Expand Down
1 change: 1 addition & 0 deletions app/services/service_provider_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def attributes
ial: protocol.ial,
aal: protocol.aal,
requested_attributes: protocol.requested_attributes,
biometric_comparison_required: protocol.biometric_comparison_required?,
uuid: request_id,
url: url,
}
Expand Down
8 changes: 6 additions & 2 deletions app/services/service_provider_request_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def self.find_or_create_by(uuid:)
return obj if obj
spr = ServiceProviderRequest.new(
uuid: uuid, issuer: nil, url: nil, ial: nil,
aal: nil, requested_attributes: nil
aal: nil, requested_attributes: nil,
biometric_comparison_required: false
)
yield(spr)
create(
Expand All @@ -43,12 +44,15 @@ def self.find_or_create_by(uuid:)
ial: spr.ial,
aal: spr.aal,
requested_attributes: spr.requested_attributes,
biometric_comparison_required: spr.biometric_comparison_required,
)
end

def self.create(hash)
uuid = hash[:uuid]
obj = hash.slice(:issuer, :url, :ial, :aal, :requested_attributes)
obj = hash.slice(
:issuer, :url, :ial, :aal, :requested_attributes, :biometric_comparison_required
)
write(obj, uuid)
hash_to_spr(obj, uuid)
end
Expand Down
1 change: 1 addition & 0 deletions app/services/store_sp_metadata_in_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def update_session
request_url: sp_request.url,
request_id: sp_request.uuid,
requested_attributes: sp_request.requested_attributes,
biometric_comparison_required: sp_request.biometric_comparison_required,
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,17 @@
request_id: sp_request_id,
request_url: request.original_url,
requested_attributes: %w[],
biometric_comparison_required: false,
)
end

it 'sets biometric_comparison_required to true if biometric comparison is required' do
params[:biometric_comparison_required] = true

action

expect(session[:sp][:biometric_comparison_required]).to eq(true)
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/saml_idp_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ def name_id_version(format_urn)
request_url: @stored_request_url.gsub('authpost', 'auth'),
request_id: sp_request_id,
requested_attributes: ['email'],
biometric_comparison_required: false,
)
end

Expand Down Expand Up @@ -1158,6 +1159,7 @@ def name_id_version(format_urn)
request_url: @saml_request.request.original_url.gsub('authpost', 'auth'),
request_id: sp_request_id,
requested_attributes: ['email'],
biometric_comparison_required: false,
)
end

Expand Down
2 changes: 2 additions & 0 deletions spec/forms/openid_connect_authorize_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
code_challenge: code_challenge,
code_challenge_method: code_challenge_method,
verified_within: verified_within,
biometric_comparison_required: biometric_comparison_required,
)
end

Expand All @@ -33,6 +34,7 @@
let(:code_challenge) { nil }
let(:code_challenge_method) { nil }
let(:verified_within) { nil }
let(:biometric_comparison_required) { nil }

describe '#submit' do
subject(:result) { form.submit }
Expand Down
39 changes: 39 additions & 0 deletions spec/services/store_sp_metadata_in_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
sp_request.ial = Saml::Idp::Constants::IAL1_AUTHN_CONTEXT_CLASSREF
sp_request.url = 'http://issuer.gov'
sp_request.requested_attributes = %w[email]
sp_request.biometric_comparison_required = false
end
instance = StoreSpMetadataInSession.new(session: app_session, request_id: request_id)

Expand All @@ -34,6 +35,7 @@
request_url: 'http://issuer.gov',
request_id: request_id,
requested_attributes: %w[email],
biometric_comparison_required: false,
}

instance.call
Expand All @@ -51,6 +53,7 @@
sp_request.aal = Saml::Idp::Constants::AAL3_AUTHN_CONTEXT_CLASSREF
sp_request.url = 'http://issuer.gov'
sp_request.requested_attributes = %w[email]
sp_request.biometric_comparison_required = false
end
instance = StoreSpMetadataInSession.new(session: app_session, request_id: request_id)

Expand All @@ -65,6 +68,7 @@
request_url: 'http://issuer.gov',
request_id: request_id,
requested_attributes: %w[email],
biometric_comparison_required: false,
}

instance.call
Expand All @@ -82,6 +86,7 @@
sp_request.aal = Saml::Idp::Constants::AAL2_PHISHING_RESISTANT_AUTHN_CONTEXT_CLASSREF
sp_request.url = 'http://issuer.gov'
sp_request.requested_attributes = %w[email]
sp_request.biometric_comparison_required = false
end
instance = StoreSpMetadataInSession.new(session: app_session, request_id: request_id)

Expand All @@ -96,6 +101,40 @@
request_url: 'http://issuer.gov',
request_id: request_id,
requested_attributes: %w[email],
biometric_comparison_required: false,
}

instance.call
expect(app_session[:sp]).to eq app_session_hash
end
end

context 'when biometric comparison is requested' do
it 'sets the session[:sp] hash' do
app_session = {}
request_id = SecureRandom.uuid
ServiceProviderRequestProxy.find_or_create_by(uuid: request_id) do |sp_request|
sp_request.issuer = 'issuer'
sp_request.ial = Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF
sp_request.aal = Saml::Idp::Constants::AAL3_AUTHN_CONTEXT_CLASSREF
sp_request.url = 'http://issuer.gov'
sp_request.requested_attributes = %w[email]
sp_request.biometric_comparison_required = true
end
instance = StoreSpMetadataInSession.new(session: app_session, request_id: request_id)

app_session_hash = {
issuer: 'issuer',
aal_level_requested: 3,
piv_cac_requested: false,
phishing_resistant_requested: true,
ial: 2,
ial2: true,
ialmax: false,
request_url: 'http://issuer.gov',
request_id: request_id,
requested_attributes: %w[email],
biometric_comparison_required: true,
}

instance.call
Expand Down