You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "turcsanyip (via GitHub)" <gi...@apache.org> on 2025/10/07 12:35:25 UTC
[PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
turcsanyip opened a new pull request, #10401:
URL: https://github.com/apache/nifi/pull/10401
…nt access tokens that have no expiration time
# Summary
[NIFI-15070](https://issues.apache.org/jira/browse/NIFI-15070)
# Tracking
Please complete the following tracking steps prior to pull request creation.
### Issue Tracking
- [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
### Pull Request Tracking
- [ ] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
- [ ] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
### Pull Request Formatting
- [ ] Pull Request based on current revision of the `main` branch
- [ ] Pull Request refers to a feature branch with one commit containing changes
# Verification
Please indicate the verification steps performed prior to pull request creation.
### Build
- [ ] Build completed using `./mvnw clean install -P contrib-check`
- [ ] JDK 21
- [ ] JDK 25
### Licensing
- [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
- [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
### Documentation
- [ ] Documentation formatting appears as expected in rendered files
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3378714145
Thanks for the reply @turcsanyip. Although this is not part of the `nifi-api`, the signature change could have theoretical impact of components built to interact with the Controller Service interface. With that being said, changing from `long` to `Long` should have minimal impact, so I'm willing to go forward with the change and updating all references in the project repository
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3576643828
@turcsanyip Are you still in the process of evaluating other changes? If it is something longer-term, perhaps it may be best to close this PR for now and revisit when ready?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3381663480
@exceptionfactory Based on further testing, it looks Salesforce expires the session even if the access token has no expiration time. So maybe it would be a better approach to add a user configurable `Expiration Time` property to `StandardOauth2AccessTokenProvider` (as in case of `JWTBearerOAuth2AccessTokenProvider`) and use this value as default when no expiration time is provided.
Please give me some time to test it thoroughly and put the review on hold till then.
Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3378636567
@exceptionfactory Thanks for highlighting this issue. Actually, the changed behavior was not applied in `JWTBearerOAuth2AccessTokenProvider` which should be adjusted. However, I would not introduce alternative methods because the real problem is that the current `getExpiredIn()` and `isExpired()` methods do not handle a valid scenario (permanent tokens). In that case we would keep `getExpiredIn()` and `isExpired()` fully compatible but containing the bug.
Instead, I would suggest modifying the type to `Long` and adjusting all usages in the codebase. As this is a component interface and is not part of `nifi-api`, I don't think we must follow strict compatibility.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on code in PR #10401:
URL: https://github.com/apache/nifi/pull/10401#discussion_r2578967985
##########
nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java:
##########
@@ -456,8 +468,10 @@ private void getProperties(ConfigurationContext context) {
}
private boolean isRefreshRequired() {
+ final long expirationTime = Optional.ofNullable(accessDetails.getExpiresIn()).orElse(defaultExpirationTimeSeconds);
Review Comment:
> The `Optional.ofNullable()` approach creates an unnecessary `Optional` wrapper. I recommend replacing this with a standard conditional
I'm not a big fan of it, but I tend to use it. I don't insist on it at all.
Just to avoid one more round: what do you think about a ternary operator? (no wrapper but still compact)
I'm also fine with the regular `if-else` if that is preferable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory merged PR #10401:
URL: https://github.com/apache/nifi/pull/10401
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3381495902
Thanks @exceptionfactory. Updated the PR with the change in `JWTBearerOAuth2AccessTokenProvider` (tested with Salesforce and also with another provider that sets the `expires_in` field).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3577442224
> @exceptionfactory Thanks for the heads-up. The improved solution has recently been tested. Will update the PR soon (later this week).
Sounds good @turcsanyip, thanks for the update!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10401:
URL: https://github.com/apache/nifi/pull/10401#discussion_r2578940918
##########
nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java:
##########
@@ -456,8 +468,10 @@ private void getProperties(ConfigurationContext context) {
}
private boolean isRefreshRequired() {
+ final long expirationTime = Optional.ofNullable(accessDetails.getExpiresIn()).orElse(defaultExpirationTimeSeconds);
Review Comment:
The `Optional.ofNullable()` approach creates an unnecessary `Optional` wrapper. I recommend replacing this with a standard conditional
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10401:
URL: https://github.com/apache/nifi/pull/10401#discussion_r2578504803
##########
nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java:
##########
@@ -456,11 +467,19 @@ private void getProperties(ConfigurationContext context) {
}
private boolean isRefreshRequired() {
- final Instant expirationRefreshTime = accessDetails.getFetchTime()
- .plusSeconds(accessDetails.getExpiresIn())
- .minusSeconds(refreshWindowSeconds);
+ if (accessDetails.getExpiresIn() != null) {
+ final Instant expirationRefreshTime = accessDetails.getFetchTime()
+ .plusSeconds(accessDetails.getExpiresIn())
+ .minusSeconds(refreshWindowSeconds);
- return Instant.now().isAfter(expirationRefreshTime);
+ return Instant.now().isAfter(expirationRefreshTime);
+ } else {
+ final Instant expirationRefreshTime = accessDetails.getFetchTime()
+ .plusSeconds(defaultExpirationTimeSeconds)
+ .minusSeconds(refreshWindowSeconds);
+
+ return Instant.now().isAfter(expirationRefreshTime);
+ }
Review Comment:
It looks like this could be refactored to a single `return` and also the value of expiration time could be the element to set conditionally so that it would read something like
```
final long expirationRefreshTime;
if (accessDetails.getExpiresIn() == null) {
expirationRefreshTime = defaultExpirationTimeSeconds;
} else {
expirationRefreshTime = accessDetails.getExpiresIn;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3381683793
> @exceptionfactory Based on further testing, it looks Salesforce expires the session even if the access token has no expiration time. So maybe it would be a better approach to add a user configurable `Expiration Time` property to `StandardOauth2AccessTokenProvider` (as in case of `JWTBearerOAuth2AccessTokenProvider`) and use this value as default when no expiration time is provided. Please give me some time to test it thoroughly and put the review on hold till then. Thanks
Thanks for the update, I will hold off on further feedback until you have run through some additional tests. Perhaps introducing a strategy property, something like `Expiration Handling` with `Access Token` and `Configured` as possible values, where `Configured` requires an explicit `Expiration Period` property could work for this generic service. I'm open to considering options. It may also require something more specific for Salesforce, so that is another thing to keep in mind in terms of scoping potential changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3577411137
@exceptionfactory Thanks for the heads-up. The improved solution has recently been tested. Will update the PR soon (later this week).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on PR #10401:
URL: https://github.com/apache/nifi/pull/10401#issuecomment-3587339920
@exceptionfactory The PR has been updated. I added `Default Expiration Time` property to `StandardOauth2AccessTokenProvider` (similar to `JWT Expiration Time` in `JWTBearerOAuth2AccessTokenProvider`). The service uses this value as default when no expiration time is provided in the access token by the OAuth server.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15070 Fixed OAuth2AccessTokenProvider to properly handle permane… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10401:
URL: https://github.com/apache/nifi/pull/10401#discussion_r2578976713
##########
nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java:
##########
@@ -456,8 +468,10 @@ private void getProperties(ConfigurationContext context) {
}
private boolean isRefreshRequired() {
+ final long expirationTime = Optional.ofNullable(accessDetails.getExpiresIn()).orElse(defaultExpirationTimeSeconds);
Review Comment:
Thanks, sure, a ternary is also fine with me, as it also avoids the unnecessary wrapper creation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org