Skip to content

Commit c600787

Browse files
committed
added key id to id token, closes mitreid-connect#725
1 parent d87bdb2 commit c600787

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

openid-connect-common/src/main/java/org/mitre/jwt/signer/service/JwtSigningAndValidationService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public interface JwtSigningAndValidationService {
7474
*/
7575
public void signJwt(SignedJWT jwt, JWSAlgorithm alg);
7676

77+
public String getDefaultSignerKeyId();
78+
7779
/**
7880
* TODO: method to sign a jwt using a specified algorithm and a key id
7981
*/

openid-connect-common/src/main/java/org/mitre/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public DefaultJwtSigningAndValidationService(JWKSetKeyStore keyStore) throws NoS
113113
/**
114114
* @return the defaultSignerKeyId
115115
*/
116+
@Override
116117
public String getDefaultSignerKeyId() {
117118
return defaultSignerKeyId;
118119
}

openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultOIDCTokenService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,21 @@ public OAuth2AccessTokenEntity createIdToken(ClientDetailsEntity client, OAuth2R
166166
} else {
167167

168168
// signed ID token
169-
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
170169

171170
if (signingAlg.equals(JWSAlgorithm.HS256)
172171
|| signingAlg.equals(JWSAlgorithm.HS384)
173172
|| signingAlg.equals(JWSAlgorithm.HS512)) {
173+
174+
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
175+
174176
JwtSigningAndValidationService signer = symmetricCacheService.getSymmetricValidtor(client);
175177

176178
// sign it with the client's secret
177179
signer.signJwt((SignedJWT) idToken);
178180
} else {
181+
idClaims.setCustomClaim("kid", jwtService.getDefaultSignerKeyId());
182+
183+
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
179184

180185
// sign it with the server's key
181186
jwtService.signJwt((SignedJWT) idToken);

0 commit comments

Comments
 (0)