Skip to content
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

Support idp cert multi with string keys #576

Merged

Conversation

alxckn
Copy link
Contributor

@alxckn alxckn commented Mar 10, 2021

I ran into issues while attempting to integrate with an ADFS IdP.
The issue was that when settings are initialized with a hash where keys are not symbols (ex. when loaded from a json file), Settings#get_idp_cert_multi is not able to retrieve the certificates.

It had been reported in this issue before: #409.

This PR proposes to fallback to string keys if symbol keys are not defined.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.004%) to 96.791% when pulling 5ec843f on alxckn:support_idp_cert_multi_with_string_keys into 61d09d0 on onelogin:master.

@johnnyshields
Copy link
Collaborator

👍 This looks good to merge

formatted_cert = OneLogin::RubySaml::Utils.format_cert(idp_cert)
certs[:encryption].push(OpenSSL::X509::Certificate.new(formatted_cert))
certs[type].push(OpenSSL::X509::Certificate.new(formatted_cert))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be:

certs[type.to_sym].push(OpenSSL::X509::Certificate.new(formatted_cert))

So we always generate certs with the symbol index, as it used to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type is a symbol, it can only be one of [:signing, :encryption]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alxckn 's code is correct here.

"encryption" => []
}
response_valid_signed.settings = settings
res = response_valid_signed.send(:validate_signature)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to this unittest, I expect one using a call to get_idp_cert_multi as well that verifies the certs were properly loaded on the settings object at settings_test.rb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests verifying that calls to get_idp_cert_multi are in fact working: 01c95db

@alxckn alxckn force-pushed the support_idp_cert_multi_with_string_keys branch from 5ec843f to 01c95db Compare September 20, 2021 21:54
@alxckn
Copy link
Contributor Author

alxckn commented Sep 20, 2021

Thanks for the review @johnnyshields, @pitbulk
Sorry for the late changes

@alxckn alxckn requested a review from pitbulk October 6, 2021 09:27
@johnnyshields
Copy link
Collaborator

@alxckn this looks ok, however, I wonder if we should coerce the settings keys to be symbols when reading in the data.

@pitbulk would suggest to merge this as-is.

@pitbulk pitbulk changed the base branch from master to ci-coveralls January 2, 2023 22:14
@pitbulk pitbulk changed the base branch from ci-coveralls to master January 2, 2023 22:14
@pitbulk pitbulk merged commit 9da1ad4 into SAML-Toolkits:master Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants