-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #31233: NimbusJwtDecoder still uses RestTemplate() instead RestTe…
…mplateBuilder (#31521)
- Loading branch information
Showing
5 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...re/spring/cloud/autoconfigure/aad/implementation/webapp/AadOidcIdTokenDecoderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.cloud.autoconfigure.aad.implementation.webapp; | ||
|
||
import org.springframework.security.oauth2.client.registration.ClientRegistration; | ||
import org.springframework.security.oauth2.core.oidc.OidcIdToken; | ||
import org.springframework.security.oauth2.jose.jws.SignatureAlgorithm; | ||
import org.springframework.security.oauth2.jwt.JwtDecoder; | ||
import org.springframework.security.oauth2.jwt.JwtDecoderFactory; | ||
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder; | ||
import org.springframework.web.client.RestOperations; | ||
|
||
/** | ||
* A factory that provides a {@link JwtDecoder} used for {@link OidcIdToken} signature verification. | ||
* | ||
* @see <a href="https://learn.microsoft.com/azure/active-directory/develop/id-tokens">azure-active-directory id-tokens</a> | ||
*/ | ||
public class AadOidcIdTokenDecoderFactory implements JwtDecoderFactory<ClientRegistration> { | ||
|
||
private final JwtDecoder jwtDecoder; | ||
|
||
/** | ||
* | ||
* @param jwkSetUri The uri of the jwk set. For example: | ||
* <a href="https://login.microsoftonline.com/common/discovery/v2.0/keys"> | ||
* https://login.microsoftonline.com/common/discovery/v2.0/keys</a> | ||
* @param restOperations The RestOperations used to retrieve jwk from jwkSetUri. | ||
*/ | ||
public AadOidcIdTokenDecoderFactory(String jwkSetUri, RestOperations restOperations) { | ||
this.jwtDecoder = NimbusJwtDecoder | ||
.withJwkSetUri(jwkSetUri) | ||
.jwsAlgorithm(SignatureAlgorithm.RS256) | ||
.restOperations(restOperations) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public JwtDecoder createDecoder(ClientRegistration context) { | ||
return jwtDecoder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters