-
Notifications
You must be signed in to change notification settings - Fork 952
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
auth_time doesn't match user's lastSignInTime (always matches iat instead) #3608
Comments
Hi @lovelle-cardoso, thanks for the report. To isolate the issue, are you only experiencing this issue using an emulator? I tried connecting or using the production (not emulator) instance and I was able to write Firestore data successfully after an hour. |
@looptheloop88 It's an emulator only issue I believe. |
Hi @lovelle-cardoso, thanks for the confirmation. Let me check this out with our engineers here and update this thread if I have any information to share. Thanks. |
Thanks for patiently waiting. I have filed an internal bug (b/194700929) for this issue. I will keep this thread posted for any updates or if I have any other information to share. |
The Auth Emulator doesn't accurately emulate As @looptheloop88 noted, we now track this internally for a fix. We are unable to promise any timeline for this, but if others also have this issue, adding a +1 on this issue can help us prioritize adding this to the roadmap. |
Looks like the problematic line is firebase-tools/src/emulator/auth/operations.ts Line 1729 in e4ab4cc
|
…s now set to user's last sign in time). (firebase#3608)
@looptheloop88 @yuchenshi All right I've submitted a PR with a fix and added a unit test for it: #3610 ^ Actually, had to delete that PR and make a new one here since my commit author wasn't correct: #3611 |
Made emulator auth_time match how auth_time is populated in production. (auth_time should match user's lastLoginAt in seconds)
@looptheloop88 @yuchenshi PR with fix and unit test is here: #3611 |
* fix: emulator auth_time (#3608) Made emulator auth_time match how auth_time is populated in production. (auth_time should match user's lastLoginAt in seconds) * Check not null just in case lastLoginAt is 0 because of unit test clock mocking * Advance clock to verify auth_time is not refresh time * assert user.lastLoginAt is not undefined * Apply suggestions from code review * Format code. Co-authored-by: Yuchen Shi <[email protected]>
* fix: emulator auth_time (firebase#3608) Made emulator auth_time match how auth_time is populated in production. (auth_time should match user's lastLoginAt in seconds) * Check not null just in case lastLoginAt is 0 because of unit test clock mocking * Advance clock to verify auth_time is not refresh time * assert user.lastLoginAt is not undefined * Apply suggestions from code review * Format code. Co-authored-by: Yuchen Shi <[email protected]>
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
According to the documentation, auth_time should match the user's last sign in time, and iat should match the time this token was issued. This means auth_time should only be updated once, when the user signed in, and iat should change every hour when a new token is issued. This is not the case however. Despite what the documentation says, auth_time changes every hour at the same time as iat. This means auth_time always matches iat, and can't be used in security rules to check the time the user last signed in
https://firebase.google.com/docs/reference/admin/node/admin.auth.DecodedIdToken#auth_time
Steps to reproduce:
npm run serve
to run the new rules in your local emulatorsExpected Result:
All reads and writes should fail for about the first hour. But after an hour has passed (and firebase has automatically issued the user a new token) the reads and writes should start succeeding
Actual Result:
All reads and writes fail forever. This is because auth_time always changes in lock-step with iat, despite the documentation saying that auth_time should remain stable after login and only iat should change every hour.
The text was updated successfully, but these errors were encountered: