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

SSO: fix settings merge for SAML fields #86970

Merged
merged 3 commits into from Apr 30, 2024
Merged

SSO: fix settings merge for SAML fields #86970

merged 3 commits into from Apr 30, 2024

Conversation

dmihai
Copy link
Contributor

@dmihai dmihai commented Apr 26, 2024

What is this feature?

With this fix we make sure that we don't merge the following fields: certificate, certificate_path, private_key, private_key_path, idp_metadata, idp_metadata_path, idp_metadata_url from system settings. We know that the DB settings already contain a valid value from each group (certificate, private_key, idp_metadata) because the DB settings has been validated before storing them into DB.

Why do we need this feature?

We don't want to have more than 1 value from a group of settings after DB and system settings has been merged.

Who is this feature for?

Anyone using SSO and SAML.

Which issue(s) does this PR fix?:

Fixes #

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@dmihai dmihai requested a review from a team April 26, 2024 09:52
@dmihai dmihai requested a review from a team as a code owner April 26, 2024 09:52
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.1.x milestone Apr 26, 2024
@dmihai dmihai added the no-changelog Skip including change in changelog/release notes label Apr 26, 2024
@@ -470,7 +470,9 @@ func mergeSettings(storedSettings, systemSettings map[string]any) map[string]any

for k, v := range systemSettings {
if _, ok := settings[k]; !ok {
settings[k] = v
if isMergingAllowed(k) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be extra defensive, should we also add a check for making sure that the isMergingAllowed is only applied to SAML settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should keep the SSO settings service as generic as possible without introducing too much logic specific to individual providers. Also at some point maybe we want to use this new functionality for Oauth as well. Client ID and client secret are good candidates there. I don't think we would ever want to merge client ID from one source (for example .ini file) with the client secret from a different source (such as SSO settings).

Copy link
Contributor

@kalleep kalleep Apr 29, 2024

Choose a reason for hiding this comment

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

I agree with @dmihai that we for sure should keep this generic and try to not add provider specific things here. Another way to do this would be to extend the provider interface with this functionality, or add an optional interface that providers can implement. That way we can make sure we don't block for other provider in case of key collision.

@dmihai dmihai merged commit 76d94b3 into main Apr 30, 2024
12 checks passed
@dmihai dmihai deleted the dmihai/sso-merge-saml branch April 30, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend no-changelog Skip including change in changelog/release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants