added key id to id token, closes #725
parent
d87bdb2120
commit
c600787f1c
|
@ -74,6 +74,8 @@ public interface JwtSigningAndValidationService {
|
||||||
*/
|
*/
|
||||||
public void signJwt(SignedJWT jwt, JWSAlgorithm alg);
|
public void signJwt(SignedJWT jwt, JWSAlgorithm alg);
|
||||||
|
|
||||||
|
public String getDefaultSignerKeyId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: method to sign a jwt using a specified algorithm and a key id
|
* TODO: method to sign a jwt using a specified algorithm and a key id
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -113,6 +113,7 @@ public class DefaultJwtSigningAndValidationService implements JwtSigningAndValid
|
||||||
/**
|
/**
|
||||||
* @return the defaultSignerKeyId
|
* @return the defaultSignerKeyId
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDefaultSignerKeyId() {
|
public String getDefaultSignerKeyId() {
|
||||||
return defaultSignerKeyId;
|
return defaultSignerKeyId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,16 +166,21 @@ public class DefaultOIDCTokenService implements OIDCTokenService {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// signed ID token
|
// signed ID token
|
||||||
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
|
|
||||||
|
|
||||||
if (signingAlg.equals(JWSAlgorithm.HS256)
|
if (signingAlg.equals(JWSAlgorithm.HS256)
|
||||||
|| signingAlg.equals(JWSAlgorithm.HS384)
|
|| signingAlg.equals(JWSAlgorithm.HS384)
|
||||||
|| signingAlg.equals(JWSAlgorithm.HS512)) {
|
|| signingAlg.equals(JWSAlgorithm.HS512)) {
|
||||||
|
|
||||||
|
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
|
||||||
|
|
||||||
JwtSigningAndValidationService signer = symmetricCacheService.getSymmetricValidtor(client);
|
JwtSigningAndValidationService signer = symmetricCacheService.getSymmetricValidtor(client);
|
||||||
|
|
||||||
// sign it with the client's secret
|
// sign it with the client's secret
|
||||||
signer.signJwt((SignedJWT) idToken);
|
signer.signJwt((SignedJWT) idToken);
|
||||||
} else {
|
} else {
|
||||||
|
idClaims.setCustomClaim("kid", jwtService.getDefaultSignerKeyId());
|
||||||
|
|
||||||
|
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
|
||||||
|
|
||||||
// sign it with the server's key
|
// sign it with the server's key
|
||||||
jwtService.signJwt((SignedJWT) idToken);
|
jwtService.signJwt((SignedJWT) idToken);
|
||||||
|
|
Loading…
Reference in New Issue