This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 5aa71570ff NIFI-9977 In StandardOauth2AccessTokenProvider add new
property to be able to set "scope".
5aa71570ff is described below
commit 5aa71570ff1781f83f9fb8bf16ed3ab386d06b85
Author: Tamas Palfy <[email protected]>
AuthorDate: Fri Apr 29 17:18:29 2022 +0200
NIFI-9977 In StandardOauth2AccessTokenProvider add new property to be able
to set "scope".
Signed-off-by: Pierre Villard <[email protected]>
This closes #6006.
---
.../oauth2/StandardOauth2AccessTokenProvider.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git
a/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java
b/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java
index 48e47ff19a..c09ecc9e96 100644
---
a/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java
+++
b/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java
@@ -122,6 +122,14 @@ public class StandardOauth2AccessTokenProvider extends
AbstractControllerService
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.build();
+ public static final PropertyDescriptor SCOPE = new
PropertyDescriptor.Builder()
+ .name("scope")
+ .displayName("Scope")
+ .description("Space-delimited, case-sensitive list of scopes of the
access request (as per the OAuth 2.0 specification)")
+ .required(false)
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+ .build();
+
public static final PropertyDescriptor REFRESH_WINDOW = new
PropertyDescriptor.Builder()
.name("refresh-window")
.displayName("Refresh Window")
@@ -146,6 +154,7 @@ public class StandardOauth2AccessTokenProvider extends
AbstractControllerService
PASSWORD,
CLIENT_ID,
CLIENT_SECRET,
+ SCOPE,
REFRESH_WINDOW,
SSL_CONTEXT
));
@@ -162,6 +171,7 @@ public class StandardOauth2AccessTokenProvider extends
AbstractControllerService
private volatile String password;
private volatile String clientId;
private volatile String clientSecret;
+ private volatile String scope;
private volatile long refreshWindowSeconds;
private volatile AccessToken accessDetails;
@@ -182,6 +192,7 @@ public class StandardOauth2AccessTokenProvider extends
AbstractControllerService
password = context.getProperty(PASSWORD).getValue();
clientId =
context.getProperty(CLIENT_ID).evaluateAttributeExpressions().getValue();
clientSecret = context.getProperty(CLIENT_SECRET).getValue();
+ scope = context.getProperty(SCOPE).getValue();
refreshWindowSeconds =
context.getProperty(REFRESH_WINDOW).asTimePeriod(TimeUnit.SECONDS);
}
@@ -264,6 +275,10 @@ public class StandardOauth2AccessTokenProvider extends
AbstractControllerService
acquireTokenBuilder.add("client_secret", clientSecret);
}
+ if (scope != null) {
+ acquireTokenBuilder.add("scope", scope);
+ }
+
RequestBody acquireTokenRequestBody = acquireTokenBuilder.build();
Request acquireTokenRequest = new Request.Builder()
@@ -286,6 +301,10 @@ public class StandardOauth2AccessTokenProvider extends
AbstractControllerService
refreshTokenBuilder.add("client_secret", clientSecret);
}
+ if (scope != null) {
+ refreshTokenBuilder.add("scope", scope);
+ }
+
RequestBody refreshTokenRequestBody = refreshTokenBuilder.build();
Request refreshRequest = new Request.Builder()