Skip to content

FIRUser decode of dates is incorrect. #1319

@jbb1003

Description

@jbb1003

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 9.3.1
  • Firebase SDK version: 4.33.0
  • Firebase Component: Auth
  • Component version: 5.0.0

[REQUIRED] Step 3: Describe the problem

The date fields of ID tokens are incorrectly decoded in current epoch.
See [FIRUser parseIDToken:error:]

NSDate *expDate =
      [NSDate dateWithTimeIntervalSinceNow:[tokenPayloadDictionary[@"exp"] doubleValue]];

They should be decoded in UNIX epoch - see https://firebase.google.com/docs/auth/admin/verify-id-tokens

exp | Expiration time | Must be in the future. The time is measured in seconds since the UNIX epoch.

Since we are now in 2018 and epoch is 1970, we end up ~48 years in the future.

Steps to reproduce:

Get an ID token with [FIRUser getIDTokenWithCompletion:]
Observe that in parseIDToken the expiration date (and other dates) ends up in 2066.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions