-
Notifications
You must be signed in to change notification settings - Fork 152
Add support for Multi-Resource Refresh Token (MRRT) #811
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
base: main
Are you sure you want to change the base?
Conversation
val expiresAt = newCredentials.expiresAt.time | ||
val willAccessTokenExpire = willExpire(expiresAt, minTtl.toLong()) | ||
if (willAccessTokenExpire) { | ||
val tokenLifetime = (expiresAt - currentTimeInMillis - minTtl * 1000) / -1000 |
Check warning
Code scanning / CodeQL
Result of multiplication cast to wider type Warning
int multiplication
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
To fix the issue, one of the operands in the multiplication should be explicitly cast to long
before the multiplication occurs. This ensures that the multiplication is performed using long
arithmetic, avoiding the risk of integer overflow. Specifically, minTtl
should be cast to long
before multiplying it by 1000.
The change should be made on line 611, where the multiplication occurs. The updated code will cast minTtl
to long
before performing the multiplication.
-
Copy modified line R611
@@ -610,3 +610,3 @@ | ||
if (willAccessTokenExpire) { | ||
val tokenLifetime = (expiresAt - currentTimeInMillis - minTtl * 1000) / -1000 | ||
val tokenLifetime = (expiresAt - currentTimeInMillis - minTtl.toLong() * 1000) / -1000 | ||
val wrongTtlException = CredentialsManagerException( |
val expiresAt = newCredentials.expiresAt.time | ||
val willAccessTokenExpire = willExpire(expiresAt, minTtl.toLong()) | ||
if (willAccessTokenExpire) { | ||
val tokenLifetime = (expiresAt - currentTimeInMillis - minTtl * 1000) / -1000 |
Check warning
Code scanning / CodeQL
Result of multiplication cast to wider type Warning
int multiplication
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
To fix the issue, we need to ensure that the multiplication minTtl * 1000
is performed in a long
context to prevent integer overflow. This can be achieved by explicitly casting one of the operands (minTtl
or 1000
) to long
before the multiplication. This ensures that the multiplication is performed as a long
operation, avoiding overflow.
The specific change will be made on line 944, where minTtl * 1000
is used. We will cast minTtl
to long
before multiplying it by 1000
.
-
Copy modified line R944
@@ -943,3 +943,3 @@ | ||
if (willAccessTokenExpire) { | ||
val tokenLifetime = (expiresAt - currentTimeInMillis - minTtl * 1000) / -1000 | ||
val tokenLifetime = (expiresAt - currentTimeInMillis - minTtl.toLong() * 1000) / -1000 | ||
val wrongTtlException = CredentialsManagerException( |
Changes
This PR moves the Credentials Manager from a single credentials model to a multiple credentials one, supporting:
1 set of app credentials (the existing functionality)
N sets of API-specific credentials
To this end, two new public methods were added to the Credentials Manager:
Testing
Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. Since this library has unit testing, tests should be added for new functionality and existing tests should complete without errors.
This change adds unit test coverage
This change adds integration test coverage
This change has been tested on the latest version of the platform/language or why not
Checklist
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors