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

introduce custom filenames for idp/sp cert/key #395

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

do9xe
Copy link
Contributor

@do9xe do9xe commented Feb 12, 2024

This PR introduces the possibility to have custom filenames for the service provider certificate and key, as well for the IdP cert.

Background
When deploying code in production environments it is common to have a dedicated folder for certificates. Especially if a server is hosting several services this folder also can contain several certificates. Having a custom filename enhances usability for administrators and gives the user more flexibility.

about this PR

  • I introduced three new methods to the settings object class to set the custom filenames
  • I had to change the order of the code in _load_settings_dict(), because it doesn't matter if we check the config before or after copying it to the protected attributes. Also, this became necessary as the protected attributes are called during config check.
  • I added the default values for the filenames
  • This closes settings parser throws "idp cert not found" exception #392
  • I added some tests in order to test against a custom filename and a non-existing filename

Tests
I ran all tests and all relevant tests passed, except for two of them, but reason for this is Windows using a different path separator and I didn't want to change the tests also.


:param settings: SAML Toolkit Settings
:type settings: dict

:returns: True if the settings info is valid
:rtype: boolean
"""
self._sp = settings.get('sp', {})
Copy link
Contributor

Choose a reason for hiding this comment

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

Order should not be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The order doesn't matter to the functionality, as the '_load_settings_from_dict' method is only called during initialization. To make the code easier I use the get_idp_cert() method to check if the config option or file actually exists and has content. Using the old order we would require way more code as the get_idp_cert() uses the data from the _idp dict (and so does the get_sp_cert() method)

@@ -328,6 +347,11 @@ def _add_default_values(self):
self._sp.setdefault('x509cert', '')
self._sp.setdefault('privateKey', '')

# Set the default filenames for the certificates and keys
self._idp.setdefault('cert_filename', 'idp.crt')
Copy link
Contributor

Choose a reason for hiding this comment

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

Better inject them in the _add_default_values method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it is already part of the _add_default_values method

@do9xe
Copy link
Contributor Author

do9xe commented Feb 26, 2024

Any further comments or can we merge this?

@do9xe
Copy link
Contributor Author

do9xe commented Mar 14, 2024

What's the status here? Can this be merged or does this patch need some additional work?

@do9xe do9xe requested a review from pitbulk May 22, 2024 07:18
@pitbulk pitbulk changed the base branch from master to fix-coveralls June 23, 2024 15:34
@pitbulk pitbulk changed the base branch from fix-coveralls to master June 23, 2024 15:34
@do9xe
Copy link
Contributor Author

do9xe commented Jul 19, 2024

Error running coveralls: Running on Github Actions but GITHUB_TOKEN is not set. Add "env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}" to your step config.

Looks like the CI pipeline has a problem

@do9xe
Copy link
Contributor Author

do9xe commented Sep 24, 2024

@pitbulk can you please check the CI or merge it manually?

@pitbulk pitbulk merged commit df213c2 into SAML-Toolkits:master Oct 1, 2024
7 of 8 checks passed
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.

settings parser throws "idp cert not found" exception
2 participants