Skip to content
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

Credentials are not refreshed properly #695

Closed
6 tasks done
nt opened this issue Oct 17, 2023 · 5 comments
Closed
6 tasks done

Credentials are not refreshed properly #695

nt opened this issue Oct 17, 2023 · 5 comments
Labels
bug This points to a verified bug in the code

Comments

@nt
Copy link

nt commented Oct 17, 2023

Checklist

Description

The library compares:

This leads to not refreshing expired credentials in timezones behind UTC.

Reproduction

  1. Set your local time to New York time
  2. Create new credentials
  3. Note the expiry time a deduct the maxTTL
  4. Wait 24 hours
  5. Request hasValidCredentials from the credential manager
  6. Notice it returns expired credentials

The issue should be clear from reading the code links I provided above.

Additional context

I am using this lib through auth0_flutter. I have not checked if the iOS impl is correct.

Auth0.Android version

auth0_flutter: ^1.2.1

Android version(s)

13

@nt nt added the bug This points to a verified bug in the code label Oct 17, 2023
@poovamraj
Copy link
Contributor

Hi @nt I am wondering whether you are mentioning the issue because of this

Request hasValidCredentials from the credential manager
Notice it returns expired credentials

Can you elaborate whether it is only hasValidCredentials that returns true? Because hasValidCredentials cannot check for validity of the refresh token as we don't get that information from the server.

If not, can you check the fix we have provided here - auth0/auth0-flutter#286

About how we compare time in the library: If you see here, you can see that the API provided time is deserialized as time specific to the device's timezone. So it shouldn't be an issue to compare it with the system's local time.

Also in the interest of keeping the conversation in one place, it is related to our Flutter SDK and also there is an issue discussing around the same thing, can we continue the conversation in this thread?

@nt
Copy link
Author

nt commented Oct 23, 2023

About how we compare time in the library: If you see here, you can see that the API provided time is deserialized as time specific to the device's timezone. So it shouldn't be an issue to compare it with the system's local time.

The issue is not with your Date or DateTime objects, it is with your conversion to seconds. https://github.com/auth0/Auth0.Android/blob/main/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt#L178
My system time does not refer to the same timezone.

Unfortunately, my system is not set up to debug java / kt and I lack the time to build a test case for you.

@poovamraj
Copy link
Contributor

@nt would love to discuss more on this and get to the bottom of it so that I can debug the SDK if there is an issue.

According to the getTime documentation

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

So if we are converting the API provided time (UTC) to system specific time and then doing the comparison in milliseconds since Jan 1 1970 00:00:00 GMT

@nt
Copy link
Author

nt commented Oct 23, 2023

@poovamraj
Copy link
Contributor

poovamraj commented Oct 23, 2023

Hey @nt as discussed over the call :) This PR should fix the issue but if not we can continue the conversation here.

I will close this thread now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

2 participants