-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add authenticator invalidate (SHOP-231) #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,19 +116,26 @@ boolean isRefreshable() | |
| return refreshExpiresAt > clock.currentTimeMillis(); | ||
| } | ||
|
|
||
| public synchronized void invalidate() | ||
| { | ||
| this.authentication = null; | ||
| this.expiresAt = -1; | ||
| this.refreshExpiresAt = -1; | ||
| } | ||
|
|
||
| private synchronized String getAccessTokenInternal() | ||
| { | ||
| this.authentication = api.authenticate(new AuthenticationRequest(userIdentifier, userSecret)); | ||
| this.expiresAt = authentication.getExpiresIn() * 1000 + System.currentTimeMillis(); | ||
| this.refreshExpiresAt = authentication.getRefreshExpiresIn() * 100 + System.currentTimeMillis(); | ||
| this.refreshExpiresAt = authentication.getRefreshExpiresIn() * 1000 + System.currentTimeMillis(); | ||
|
Comment on lines
-123
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like the real fix is this one?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is THE fix, it will reduce full re-authentication count, the only downside of having 100 vs 1000 is the frequency of full re-authentications vs refreshes. |
||
| return authentication.getAccessToken(); | ||
| } | ||
|
|
||
| private synchronized String refreshAccessToken() | ||
| { | ||
| this.authentication = api.refresh(new AuthenticationRefreshRequest(authentication.getRefreshToken())); | ||
| this.expiresAt = authentication.getExpiresIn() * 1000 + System.currentTimeMillis(); | ||
| this.refreshExpiresAt = authentication.getRefreshExpiresIn() * 100 + System.currentTimeMillis(); | ||
| this.refreshExpiresAt = authentication.getRefreshExpiresIn() * 1000 + System.currentTimeMillis(); | ||
| return authentication.getAccessToken(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not called by anyone, isn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to use it in https://github.com/Smartling/connectors-export-service/pull/97/changes#diff-eba6a586acd2df1c46841b76ac26172168b0e36ecc51ce56c44400f336660da5R17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that filter is only for logging. your http client from sdk already gets 401 response isn't? why can't you handle this 401 in sdk directly?