GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [fix][client] Expire cached OAuth2 tokens before the broker sees them expired by merlimat · Pull Request #27522 · apache/pulsar Conversation
Contributor
Motivation
When the broker's periodic refresh check ( This also makes The producer is reconnecting because the broker closed its connection. Broker log of the failure: Current code path: // AuthenticationOAuth2 public synchronized AuthenticationDataProvider getAuthData() throws PulsarClientException { ... if (this.cachedToken == null || this.cachedToken.isExpired()) { this.authenticate(); } return this.cachedToken.getAuthData(); // the broker's REFRESH gets the cached token back } // AuthenticationOAuth2.CachedToken: counted from when the response arrived this.expiresAt = AuthenticationOAuth2.this.clock.instant().plusSeconds(latest.getExpiresIn()); // AuthenticationProviderToken.TokenAuthenticationState, checked by ServerCnx.refreshAuthenticationCredentials() public boolean isExpired() { return expiration < System.currentTimeMillis(); // expiration is the JWT exp claim, in whole seconds } ModificationsCount the token's lifetime from when it was requested, less one second for the whole-second private void authenticate() throws PulsarClientException { ... Instant requestedAt = this.clock.instant(); TokenResult tr = this.flow.authenticate(); this.cachedToken = new CachedToken(tr, requestedAt); handleSuccessfulTokenRefresh(); } public CachedToken(TokenResult latest, Instant requestedAt) { this.latest = latest; this.expiresAt = requestedAt.plusSeconds(latest.getExpiresIn()).minusSeconds(1); ... } The identity provider issues the token after the request is sent, and the Behavior notes:
Verifying this change
Does this pull request potentially affect one of the following parts:If the box was checked, please highlight the changes
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions… expired AuthenticationOAuth2 cached a token until expires_in seconds after the token response arrived. The broker goes by the token's exp claim, which the identity provider counts from when it issued the token, in whole seconds, so it can be up to a second plus the identity provider round trip earlier. A broker refresh check in that gap got the cached token back, rejected it as expired and closed the connection, and the client's reconnects failed the same way until its cache expired. Count the token's lifetime from when it was requested, less one second for the whole-second exp claim, so the client has dropped the token by the time the broker sees it expired. This also fixes the flaky TokenOauth2AuthenticatedProducerConsumerTest.testOAuth2TokenRefreshedWithoutReconnect. …oken-refresh-flaky
codelipenghui
approved these changes
Uh oh!
There was an error while loading. Please reload this page.
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
… expired (apache#27522) (cherry picked from commit e35988b)
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
… expired (apache#27522) (cherry picked from commit e35988b)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |