Skip to content

Commit

Permalink
feat: add oauth scope (for entra id) (#110) (#112)
Browse files Browse the repository at this point in the history
* feat: add oauth scope (for entra id) (#110)

(cherry picked from commit 40138fc)

* saas does not require a scope

---------

Co-authored-by: TN <[email protected]>
  • Loading branch information
jonathanlukas and tea-one authored Oct 16, 2024
1 parent 1a38195 commit 21f8ea7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ private static JwtAuthentication jwtAuthentication(JwtConfig jwtConfig, JsonMapp
jwtCredential.getClientId(),
jwtCredential.getClientSecret(),
jwtCredential.getAudience(),
URI.create(jwtCredential.getAuthUrl()).toURL());
URI.create(jwtCredential.getAuthUrl()).toURL(),
null);
} catch (MalformedURLException e) {
throw new RuntimeException("Error while mapping jwt credential", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private HttpPost buildRequest() throws URISyntaxException {
formParams.add(new BasicNameValuePair("client_id", jwtCredential.clientId()));
formParams.add(new BasicNameValuePair("client_secret", jwtCredential.clientSecret()));
formParams.add(new BasicNameValuePair("audience", jwtCredential.audience()));
formParams.add(new BasicNameValuePair("scope", jwtCredential.scope()));
httpPost.setEntity(new UrlEncodedFormEntity(formParams));
return httpPost;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

import java.net.URL;

public record JwtCredential(String clientId, String clientSecret, String audience, URL authUrl) {}
public record JwtCredential(
String clientId, String clientSecret, String audience, URL authUrl, String scope) {}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public Authentication authentication() {
properties.clientId(),
properties.clientSecret(),
properties.audience(),
properties.authUrl()),
properties.authUrl(),
properties.scope()),
new JacksonTokenResponseMapper(objectMapper));
}
default -> throw new IllegalStateException("Unsupported profile: " + properties.profile());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public record OperateClientConfigurationProperties(
String clientSecret,
URL authUrl,
String audience,
String scope,
// saas auth properies
String region,
String clusterId) {
Expand Down

0 comments on commit 21f8ea7

Please sign in to comment.