Use client id from trusted issuer in oidc token verifier. #12530
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.
Description
Changed OIDC token verifier behaviour to read a client id from trusted issuer map. At present the tools reads a client id from command line flag. This approach will not work with more than one client applications. Each client application should provide it's own client id in a oidc token audience claim. This is to prevent hijacking a token from other application in the same oidc token provider and leveraging a hijacked permissions. With client id provided as flag we would have to know the valid expected client id before running the tool.
The PR propose to define valid client id in Issuer. After reading an issuer from token and matching it with trusted issuers, we can set correct expected client id and run oidc token verification against uniq client id/audience value.
Changes proposed in this pull request:
ClientID
field to the Issuer struct and defined current default value for github.com an github.tools.sap oidc providers.It's a TokenProcessor method now and does not expect a clientID string as argument. Moved function implementation closer to the TokenProcessor implementation to maintain consistency.
The clientID value is read from trusted issuer in TokenProcessor instance.
Moved a test for empty client id scenario to the unit tests file because to client id provided by TokenProcessor can't be modified outside a package.
Added more expectations in test for providing a valid default verifier config scenario.
It does not expect a VerifierConfig as argument anymore. The config is expected to be created after creating a TokenProcessor instance, because a TokenProcessor provides an expected client id value.
The function verifies if matched trusted issuer has non empty ClientID value.
Swapped order of creating a VerifierConfig and TokenProcessor instances. A TokenProcessor must be created first in order to provide a trusted issuer with expected client id value.
Removed unused client-id command line flag and options field.
Added more debug logs.
Removed trusted workflows command line flag and options field.
Aligned tests to the changes.
Regenerated mocks to align with changes.