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

Add azp to JWKS endpoint headers #1285

Merged
merged 25 commits into from
Oct 13, 2023
Merged

Conversation

finkmanAtSap
Copy link
Contributor

No description provided.

Copy link
Contributor

@liga-oz liga-oz left a comment

Choose a reason for hiding this comment

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

Some things to consider, see comments.

@finkmanAtSap finkmanAtSap requested a review from mwdb September 25, 2023 12:45
@finkmanAtSap
Copy link
Contributor Author

Split JwtSignatureValidator into two service-specific implementations to clean up its code and prepare for service-specific retrieval of JWKS in future refactorings.

@finkmanAtSap finkmanAtSap requested review from mwdb and liga-oz October 2, 2023 14:57
Copy link
Contributor

@liga-oz liga-oz left a comment

Choose a reason for hiding this comment

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

All in all really nice job 💯
I'm just troubled by the number of arguments that TokenKeyService method retrieveTokenKeys and OAuth2TokenKeyServiceWithCache.getPublicKey(JwtSignatureAlgorithm keyAlgorithm, String keyId, URI keyUri, String appTid, String clientId, String azp) introduces, it should be refactored and a new class should be introduced that encapsulates all the required header parameters.

@finkmanAtSap
Copy link
Contributor Author

All in all really nice job 💯 I'm just troubled by the number of arguments that TokenKeyService method retrieveTokenKeys and OAuth2TokenKeyServiceWithCache.getPublicKey(JwtSignatureAlgorithm keyAlgorithm, String keyId, URI keyUri, String appTid, String clientId, String azp) introduces, it should be refactored and a new class should be introduced that encapsulates all the required header parameters.

I used a Map<String, String> now to pass the parameters since the required parameters are different for XSUAA and IAS and I do not think a dedicated class can be defined with the required parameters that works for both services.

@@ -77,7 +67,7 @@
.build();
}

LOGGER.debug("Successfully retrieved token keys from {} for tenant '{}'", tokenKeysEndpointUri, tenantId);
LOGGER.debug("Successfully retrieved token keys from {} with params {}.", tokenKeysEndpointUri, params);

Check failure

Code scanning / CodeQL

Insertion of sensitive information into log files

This [potentially sensitive information](1) is written to a log file.
try {
ResponseEntity<String> response = restOperations.exchange(
tokenKeysEndpointUri, GET, new HttpEntity<>(headers), String.class);
if (HttpStatus.OK.value() == response.getStatusCode().value()) {
LOGGER.debug("Successfully retrieved token keys from {} for tenant '{}'", tokenKeysEndpointUri, tenantId);
LOGGER.debug("Successfully retrieved token keys from {} for params '{}'", tokenKeysEndpointUri, params);

Check failure

Code scanning / CodeQL

Insertion of sensitive information into log files

This [potentially sensitive information](1) is written to a log file.
@finkmanAtSap finkmanAtSap requested a review from liga-oz October 12, 2023 09:47
Copy link
Contributor

@liga-oz liga-oz left a comment

Choose a reason for hiding this comment

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

lgtm, so much cleaner with the map as param 👍🏻 just check the 2 comments before merging.

@finkmanAtSap finkmanAtSap merged commit 07895cf into main Oct 13, 2023
@finkmanAtSap finkmanAtSap deleted the hotfix/jwksEndpointHeaders branch October 13, 2023 12:19
finkmanAtSap added a commit that referenced this pull request Oct 16, 2023
* add x-azp header to JWKS fetching and adjust JWKS cache key
* refactor JwtSignatureValidator -> Split into XsuaaJwtSignatureValidator and SapIdJwtSignatureValidator
* refactor OAuth2TokenKeyService and OAuth2TokenKeyServiceWithCache APIs to use generic Map instead of explicit IAS-specific parameters

---------

Co-authored-by: liga-oz <liga.ozolina@sap.com>
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.

3 participants