Skip to content

Commit

Permalink
feat: add resource parameter to the OAuth2 token request to follow RF…
Browse files Browse the repository at this point in the history
…C-8707
  • Loading branch information
scandinave committed Dec 17, 2024
1 parent abdc001 commit 223dfd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private Oauth2CredentialsRequest createRequest(TokenParameters parameters, Strin
.url(tokenUrl)
.clientAssertion(assertion)
.scope(parameters.getStringClaim(JwtRegisteredClaimNames.SCOPE))
.resource(parameters.getStringClaim(JwtRegisteredClaimNames.AUDIENCE))
.grantType(GRANT_TYPE)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public abstract class Oauth2CredentialsRequest {

private static final String GRANT_TYPE = "grant_type";
private static final String SCOPE = "scope";
private static final String RESOURCE = "resource";

protected String url;
protected final Map<String, String> params = new HashMap<>();
Expand Down Expand Up @@ -80,12 +81,17 @@ public B params(Map<String, String> params) {
return self();
}

public B resource(String targetedAudience) {
return param(RESOURCE, targetedAudience);
}

public abstract B self();

protected T build() {
Objects.requireNonNull(request.url, "url");
Objects.requireNonNull(request.params.get(GRANT_TYPE), GRANT_TYPE);
return request;
}

}
}

0 comments on commit 223dfd1

Please sign in to comment.