Skip to content

Commit

Permalink
Issue1568 (networknt#1569)
Browse files Browse the repository at this point in the history
* fixes networknt#1566 update the JwtVerifyHandler to cache the jwk with prefix as part of the key

* fixes networknt#1568 update mras handler to send client_id and client_secret in body
  • Loading branch information
stevehu authored Jan 10, 2023
1 parent c3fbce2 commit 9dd8277
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class MrasConfig {
public static final String TOKEN_URL = "tokenUrl";
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String CLIENT_ID = "clientId";
public static final String CLIENT_SECRET = "clientSecret";
public static final String RESOURCE = "resource";
public static final String CACHE_ENABLED = "cacheEnabled";
public static final String MEM_KEY = "memKey";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ private Result<TokenResponse> getMicrosoftToken() throws Exception {
Map<String, String> parameters = new HashMap<>();
parameters.put("grant_type", "client_credentials");
parameters.put("resource", (String)config.getMicrosoft().get(config.RESOURCE));
parameters.put("client_id", (String)config.getMicrosoft().get(config.CLIENT_ID));
parameters.put("client_secret", (String)config.getMicrosoft().get(config.CLIENT_SECRET));

String form = parameters.entrySet()
.stream()
Expand All @@ -404,7 +406,7 @@ private Result<TokenResponse> getMicrosoftToken() throws Exception {

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(serverUrl))
.headers("Content-Type", "application/x-www-form-urlencoded", "Authorization", "BASIC " + encodeCredentials((String)config.getMicrosoft().get(config.USERNAME), (String)config.getMicrosoft().get(config.PASSWORD)))
.headers("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString(form))
.build();

Expand Down
4 changes: 2 additions & 2 deletions ingress-proxy/src/main/resources/config/mras.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ microsoft:
# MRAS get token URL to send the request
tokenUrl: ${mras.microsoft.tokenUrl:https://test.mras.com/services/oauth2/token}
# username for the authentication
username: ${mras.microsoft.username:}
clientId: ${mras.microsoft.clientId:}
# password for the authentication
password: ${mras.microsoft.password:}
clientSecret: ${mras.microsoft.clientSecret:}
# resource for the authentication
resource: ${mras.microsoft.resource:}
# is cache enabled for the token
Expand Down
4 changes: 2 additions & 2 deletions ingress-proxy/src/test/resources/config/values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ mras.accessToken.gracePeriod: 50

mras.microsoft.serviceHost: https://localhost:8443
mras.microsoft.tokenUrl: https://test.mras.com/services/oauth2/token
mras.microsoft.username: client_id
mras.microsoft.password: client_secret
mras.microsoft.clientId: client_id
mras.microsoft.clientSecret: client_secret
mras.microsoft.cacheEnabled: true
mras.microsoft.memKey: MRASToken
mras.microsoft.gracePeriod: 50
Expand Down

0 comments on commit 9dd8277

Please sign in to comment.