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

Fix bug where auth metadata in the auth blocking tokens are assumed to be seconds not miliseconds #1472

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Remove HTTP server shutdown message. (#1457)
- Add features to task queue functions. (#1423)
- Add traces to V2 Firestore trigger logs. (#1440)
- Fix incorrectly parsed timestamps in auth blocking functions. (#1472)
12 changes: 6 additions & 6 deletions spec/common/providers/identity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ describe("identity", () => {

describe("parseMetadata", () => {
const decodedMetadata = {
last_sign_in_time: 1476235905,
creation_time: 1476136676,
last_sign_in_time: 1476235905000,
creation_time: 1476136676000,
};
const metadata = {
lastSignInTime: new Date(1476235905000).toUTCString(),
Expand Down Expand Up @@ -374,8 +374,8 @@ describe("identity", () => {
photo_url: "https://lh3.googleusercontent.com/1234567890/photo.jpg",
tokens_valid_after_time: 1476136676,
metadata: {
last_sign_in_time: 1476235905,
creation_time: 1476136676,
last_sign_in_time: 1476235905000,
creation_time: 1476136676000,
},
custom_claims: {
admin: true,
Expand Down Expand Up @@ -632,8 +632,8 @@ describe("identity", () => {
photo_url: "https://lh3.googleusercontent.com/1234567890/photo.jpg",
tokens_valid_after_time: 1476136676,
metadata: {
last_sign_in_time: 1476235905,
creation_time: 1476136676,
last_sign_in_time: 1476235905000,
creation_time: 1476136676000,
},
custom_claims: {
admin: true,
Expand Down
4 changes: 2 additions & 2 deletions src/common/providers/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ function unsafeDecodeAuthBlockingToken(token: string): DecodedPayload {
*/
export function parseMetadata(metadata: DecodedPayloadUserRecordMetadata): AuthUserMetadata {
const creationTime = metadata?.creation_time
? new Date(metadata.creation_time * 1000).toUTCString()
? new Date(metadata.creation_time).toUTCString()
: null;
const lastSignInTime = metadata?.last_sign_in_time
? new Date(metadata.last_sign_in_time * 1000).toUTCString()
? new Date(metadata.last_sign_in_time).toUTCString()
: null;
return {
creationTime,
Expand Down
Loading