Skip to content

Commit f423dc3

Browse files
Merge commit from fork
fix: remove :idp_cert_fingerprint_validator
2 parents 553b8dd + c573690 commit f423dc3

File tree

3 files changed

+3
-58
lines changed

3 files changed

+3
-58
lines changed

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use OmniAuth::Strategies::SAML,
3939
:encryption => []
4040
},
4141
:idp_cert_fingerprint => "E7:91:B2:E1:...",
42-
:idp_cert_fingerprint_validator => lambda { |fingerprint| fingerprint },
4342
:name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
4443
```
4544

@@ -66,7 +65,6 @@ Rails.application.config.middleware.use OmniAuth::Builder do
6665
:encryption => []
6766
},
6867
:idp_cert_fingerprint => "E7:91:B2:E1:...",
69-
:idp_cert_fingerprint_validator => lambda { |fingerprint| fingerprint },
7068
:name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
7169
end
7270
```
@@ -112,20 +110,16 @@ Note that when [integrating with Devise](#devise-integration), the URL path will
112110
`original_param_value`. Optional.
113111

114112
* `:idp_cert` - The identity provider's certificate in PEM format. Takes precedence
115-
over the fingerprint option below. This option or `:idp_cert_multi` or `:idp_cert_fingerprint` or `:idp_cert_fingerprint_validator` must
113+
over the fingerprint option below. This option or `:idp_cert_multi` or `:idp_cert_fingerprint` must
116114
be present.
117115

118116
* `:idp_cert_multi` - Multiple identity provider certificates in PEM format. Takes precedence
119-
over the fingerprint option below. This option `:idp_cert` or `:idp_cert_fingerprint` or `:idp_cert_fingerprint_validator` must
117+
over the fingerprint option below. This option `:idp_cert` or `:idp_cert_fingerprint` must
120118
be present.
121119

122120
* `:idp_cert_fingerprint` - The SHA1 fingerprint of the certificate, e.g.
123121
"90:CC:16:F0:8D:...". This is provided from the identity provider when setting up
124-
the relationship. This option or `:idp_cert` or `:idp_cert_multi` or `:idp_cert_fingerprint_validator` MUST be present.
125-
126-
* `:idp_cert_fingerprint_validator` - A lambda that MUST accept one parameter
127-
(the fingerprint), verify if it is valid and return it if successful. This option
128-
or `:idp_cert` or `:idp_cert_multi` or `:idp_cert_fingerprint` MUST be present.
122+
the relationship. This option or `:idp_cert` or `:idp_cert_multi` MUST be present.
129123

130124
* `:name_identifier_format` - Used during SP-initiated SSO. Describes the format of
131125
the username required by this application. If you need the email address, use

lib/omniauth/strategies/saml.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ def callback_phase
4343
raise OmniAuth::Strategies::SAML::ValidationError.new("SAML response missing") unless request.params["SAMLResponse"]
4444

4545
with_settings do |settings|
46-
# Call a fingerprint validation method if there's one
47-
validate_fingerprint(settings) if options.idp_cert_fingerprint_validator
48-
4946
handle_response(request.params["SAMLResponse"], options_for_response_object, settings) do
5047
super
5148
end
@@ -218,17 +215,6 @@ def with_settings
218215
yield OneLogin::RubySaml::Settings.new(options)
219216
end
220217

221-
def validate_fingerprint(settings)
222-
fingerprint_exists = options.idp_cert_fingerprint_validator[response_fingerprint]
223-
224-
unless fingerprint_exists
225-
raise OmniAuth::Strategies::SAML::ValidationError.new("Non-existent fingerprint")
226-
end
227-
228-
# id_cert_fingerprint becomes the given fingerprint if it exists
229-
settings.idp_cert_fingerprint = fingerprint_exists
230-
end
231-
232218
def options_for_response_object
233219
# filter options to select only extra parameters
234220
opts = options.select {|k,_| RUBYSAML_RESPONSE_OPTIONS.include?(k.to_sym)}

spec/omniauth/strategies/saml_spec.rb

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -150,41 +150,6 @@ def post_xml(xml = :example_response, opts = {})
150150
end
151151
end
152152

153-
context "when fingerprint is empty and there's a fingerprint validator" do
154-
before :each do
155-
saml_options.delete(:idp_cert_fingerprint)
156-
saml_options[:idp_cert_fingerprint_validator] = fingerprint_validator
157-
end
158-
159-
let(:fingerprint_validator) { lambda { |_| "C1:59:74:2B:E8:0C:6C:A9:41:0F:6E:83:F6:D1:52:25:45:58:89:FB" } }
160-
161-
context "when the fingerprint validator returns a truthy value" do
162-
before { post_xml }
163-
164-
it "should set the uid to the nameID in the SAML response" do
165-
expect(auth_hash['uid']).to eq '_1f6fcf6be5e13b08b1e3610e7ff59f205fbd814f23'
166-
end
167-
168-
it "should set the raw info to all attributes" do
169-
expect(auth_hash['extra']['raw_info'].all.to_hash).to eq(
170-
'first_name' => ['Rajiv'],
171-
'last_name' => ['Manglani'],
172-
'email' => ['[email protected]'],
173-
'company_name' => ['Example Company'],
174-
'fingerprint' => 'C1:59:74:2B:E8:0C:6C:A9:41:0F:6E:83:F6:D1:52:25:45:58:89:FB'
175-
)
176-
end
177-
end
178-
179-
context "when the fingerprint validator returns false" do
180-
let(:fingerprint_validator) { lambda { |_| false } }
181-
182-
before { post_xml }
183-
184-
it { is_expected.to fail_with(:invalid_ticket) }
185-
end
186-
end
187-
188153
context "when the assertion_consumer_service_url is the default" do
189154
before :each do
190155
saml_options.delete(:assertion_consumer_service_url)

0 commit comments

Comments
 (0)