Skip to content

Use configured ID Token signature algorithm #787

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

Closed
wants to merge 5 commits into from
Closed

Use configured ID Token signature algorithm #787

wants to merge 5 commits into from

Conversation

721806280
Copy link
Contributor

No description provided.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 20, 2022
@jgrandja jgrandja changed the title Update JwtGenerator.java Use default ID Token signature algorithm Jul 19, 2022
@jgrandja jgrandja self-assigned this Jul 19, 2022
@jgrandja jgrandja added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 19, 2022
@jgrandja jgrandja added this to the 0.4.0-M1 milestone Jul 19, 2022
Copy link
Collaborator

@jgrandja jgrandja left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @721806280. Please see review comment.

@@ -125,7 +125,7 @@ public Jwt generate(OAuth2TokenContext context) {
}
// @formatter:on

JwsHeader.Builder headersBuilder = JwsHeader.with(SignatureAlgorithm.RS256);
JwsHeader.Builder headersBuilder = JwsHeader.with(registeredClient.getTokenSettings().getIdTokenSignatureAlgorithm());
Copy link
Collaborator

Choose a reason for hiding this comment

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

registeredClient.getTokenSettings().getIdTokenSignatureAlgorithm() should only be used when minting an ID Token. The existing default should be preserved for access tokens.

@jgrandja jgrandja changed the title Use default ID Token signature algorithm Use configured ID Token signature algorithm Jul 19, 2022
Copy link
Collaborator

@jgrandja jgrandja left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @721806280. Please see review comments.

Also, please rebase off of 0.4.x and squash the commits on next push. Thanks.

@@ -15,10 +15,6 @@
*/
package org.springframework.security.oauth2.server.authorization.token;

import java.time.Instant;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this change. Only apply changes to required code.

@@ -30,29 +26,29 @@
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
import org.springframework.security.oauth2.core.oidc.endpoint.OidcParameterNames;
import org.springframework.security.oauth2.jose.jws.SignatureAlgorithm;
import org.springframework.security.oauth2.jwt.JwsHeader;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this change. Only apply changes to required code.

/**
* An {@link OAuth2TokenGenerator} that generates a {@link Jwt}
* used for an {@link OAuth2AccessToken} or {@link OidcIdToken}.
*
* @author Joe Grandja
* @since 0.2.3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this change. Only apply changes to required code.

} else {
expiresAt = issuedAt.plus(registeredClient.getTokenSettings().getAccessTokenTimeToLive());
headersBuilder = JwsHeader.with(registeredClient.getTokenSettings().getIdTokenSignatureAlgorithm());
Copy link
Collaborator

@jgrandja jgrandja Aug 16, 2022

Choose a reason for hiding this comment

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

This line should be under the if statement -> if (OidcParameterNames.ID_TOKEN.equals(context.getTokenType().getValue()))

Also, please add a test to ensure the defaults are set as expected.

@jgrandja jgrandja modified the milestones: 0.4.0-M1, 0.4.0-M2 Aug 16, 2022
Copy link
Collaborator

@jgrandja jgrandja left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @721806280. Please see the one review comment.

In addition to the one requested change, please add a test in JwtGeneratorTests to ensure the defaults are set as expected. Also, please rebase this PR off of 0.4.x branch and squash the commits.
Thanks.

@@ -89,9 +89,11 @@ public Jwt generate(OAuth2TokenContext context) {

Instant issuedAt = Instant.now();
Instant expiresAt;
JwsHeader.Builder headersBuilder = JwsHeader.with(SignatureAlgorithm.RS256);
Copy link
Collaborator

Choose a reason for hiding this comment

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

To prevent JwsHeader.Builder from being instantiated twice, please add JwsHeader.with(SignatureAlgorithm.RS256) under the else

@721806280 721806280 changed the base branch from main to 0.4.x August 28, 2022 07:53
jgrandja pushed a commit that referenced this pull request Aug 30, 2022
jgrandja added a commit that referenced this pull request Aug 30, 2022
@jgrandja
Copy link
Collaborator

Thanks for the PR @721806280. This is now merged.

FYI, I added a polish commit with some minor updates.

@jgrandja jgrandja closed this Aug 30, 2022
jgrandja added a commit that referenced this pull request Sep 13, 2022
The following commits are merged using the default merge strategy.

70d433a Update ref-doc with OAuth2Authorization.getAuthorizedScopes()
0994a1e Allow customizing OIDC Provider Configuration Response
8043b8c Allow customizing Authorization Server Metadata Response
4466cbe Use configured ID Token signature algorithm
502fa24 Polish gh-787
07d69cb Validate client secret not expired
2cc603c Improve configurability for AuthenticationConverter and AuthenticationProvider
1db0599 Make OAuth2AuthenticationContext an interface
c326b1a Remove OAuth2AuthenticationValidator
doba16 pushed a commit to doba16/spring-authorization-server that referenced this pull request Apr 21, 2023
doba16 pushed a commit to doba16/spring-authorization-server that referenced this pull request Apr 21, 2023
doba16 pushed a commit to doba16/spring-authorization-server that referenced this pull request Apr 21, 2023
The following commits are merged using the default merge strategy.

adfb603 Update ref-doc with OAuth2Authorization.getAuthorizedScopes()
3f1d4c8 Allow customizing OIDC Provider Configuration Response
2be31fb Allow customizing Authorization Server Metadata Response
bf1b85b Use configured ID Token signature algorithm
98c4d1c Polish spring-projectsgh-787
b4a6ba8 Validate client secret not expired
525c084 Improve configurability for AuthenticationConverter and AuthenticationProvider
f545816 Make OAuth2AuthenticationContext an interface
333837d Remove OAuth2AuthenticationValidator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants