aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase
diff options
context:
space:
mode:
authorGravatar Morgan Chen <morganchen12@gmail.com>2018-06-25 14:30:31 -0700
committerGravatar Morgan Chen <morganchen12@gmail.com>2018-06-25 14:32:54 -0700
commit17af03b58183f34ad1d1f0f46995315e67f43031 (patch)
treeb0a39ffb5f4ba61e715136ef1f5447e39cb07333 /Firebase
parentf2c102887bb59074bc85a0473b93eb33f5244aac (diff)
Fix bad JWT parsing
Diffstat (limited to 'Firebase')
-rw-r--r--Firebase/Auth/CHANGELOG.md3
-rw-r--r--Firebase/Auth/Source/FIRUser.m8
2 files changed, 8 insertions, 3 deletions
diff --git a/Firebase/Auth/CHANGELOG.md b/Firebase/Auth/CHANGELOG.md
index 2669fc0..d70626b 100644
--- a/Firebase/Auth/CHANGELOG.md
+++ b/Firebase/Auth/CHANGELOG.md
@@ -1,3 +1,6 @@
+# v5.0.3
+- Fix an issue where JWT date timestamps weren't parsed correctly.
+
# v5.0.2
- Fix an issue where anonymous accounts weren't correctly promoted to
non-anonymous when linked with passwordless email auth accounts.
diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m
index 3f5bf35..9bae744 100644
--- a/Firebase/Auth/Source/FIRUser.m
+++ b/Firebase/Auth/Source/FIRUser.m
@@ -890,12 +890,14 @@ static void callInMainThreadWithAuthDataResultAndError(
return nil;
}
+ // These are dates since 00:00:00 January 1 1970, as described by the Terminology section in
+ // the JWT spec. https://tools.ietf.org/html/rfc7519
NSDate *expDate =
- [NSDate dateWithTimeIntervalSinceNow:[tokenPayloadDictionary[@"exp"] doubleValue]];
+ [NSDate dateWithTimeIntervalSince1970:[tokenPayloadDictionary[@"exp"] doubleValue]];
NSDate *authDate =
- [NSDate dateWithTimeIntervalSinceNow:[tokenPayloadDictionary[@"auth_time"] doubleValue]];
+ [NSDate dateWithTimeIntervalSince1970:[tokenPayloadDictionary[@"auth_time"] doubleValue]];
NSDate *issuedDate =
- [NSDate dateWithTimeIntervalSinceNow:[tokenPayloadDictionary[@"iat"] doubleValue]];
+ [NSDate dateWithTimeIntervalSince1970:[tokenPayloadDictionary[@"iat"] doubleValue]];
FIRAuthTokenResult *result =
[[FIRAuthTokenResult alloc] initWithToken:token
expirationDate:expDate