Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This makes the prometheus-auth more flexible, in case a non-caas OIDC issuer should be used.
Changes done
The provider URL is now passed directly via a CLI flag. There is validation done directly, in case a URL should be passed.
To make sure that no OIDC Issuers with a URL of
""
are used (the nil value of the CLI string when a flag isn't provided), a simple struct namedoidc
was introduced, with anactive
property, which is only set, if the issuer URL passed can be actually parsed.Discussion
To accommodate this change, the
switch
statement was replaced with multiple ifs. This was in case the user hasn't provided an Issuer URL and in case the claim should have an empty Issuer URL (which shouldn't happen according to the RfC https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1, but wilder things have happened). Just playing it safe should be OK, I guess and we're not sacrificing too much readability here.Tests done
Tested in an rke1 and rke2 staging cluster with different OIDC Issuer URLs. The validation works as it did before.