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

App Check: optimize auto-refresh #8232

Merged
merged 51 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ff204f3
App Attest provider: attestation sequence (#7971)
maksymmalyhin Apr 26, 2021
869f87c
Implement app attest key ID storage (#8014)
ncooke3 May 3, 2021
f2b77f0
Merge branch 'master' into appcheck-appattest-main
maksymmalyhin May 4, 2021
39ae2d3
App Check App Attest workflow updates: initial handshake (#8032)
maksymmalyhin May 5, 2021
ccac49c
FIRAppAttestArtifactStorage implementation and tests (#8041)
maksymmalyhin May 5, 2021
c7558b5
Implement App Attest `getRandomChallenge` (#8033)
ncooke3 May 6, 2021
e7f1ff8
Merge branch 'master' into appcheck-appattest-main
maksymmalyhin May 6, 2021
ed07e4b
Define Exchange AppAttest Assertion for FAC token API (#8058)
ncooke3 May 11, 2021
67b5c3a
Merge branch 'master' into appcheck-appattest-main
maksymmalyhin May 11, 2021
786f613
App Check App Attest: attestation request (#8059)
maksymmalyhin May 12, 2021
6742e33
Merge branch 'master' into appcheck-appattest-main
maksymmalyhin May 12, 2021
a35d7bd
App Check App Attest initial handshake adjustments (#8067)
maksymmalyhin May 12, 2021
2b16a5f
Merge remote-tracking branch 'origin/master' into appcheck-appattest-…
maksymmalyhin May 13, 2021
c2bb06b
Implement API for ExchangeAppAttestAssertionRequest endpoint (#8065)
ncooke3 May 13, 2021
cd53ea8
Merge remote-tracking branch 'origin/master' into appcheck-appattest-…
maksymmalyhin May 14, 2021
e04a789
Merge branch 'appcheck-appattest-main' of github.com:firebase/firebas…
maksymmalyhin May 14, 2021
ac17a23
App Check App Attest assertion flow (#8083)
maksymmalyhin May 17, 2021
b9d638e
Merge remote-tracking branch 'origin/master' into appcheck-appattest-…
maksymmalyhin May 17, 2021
cea2f68
App Check: store App Attest artifact per key ID (#8097)
maksymmalyhin May 18, 2021
2b70bf0
App Check: prevent concurrent token requests (#8117)
maksymmalyhin May 21, 2021
f134778
Merge remote-tracking branch 'origin/master' into appcheck-appattest-…
maksymmalyhin May 21, 2021
2102187
Changelog
maksymmalyhin May 21, 2021
c0650aa
Merge branch 'master' into appcheck-appattest-main
maksymmalyhin May 31, 2021
b8f80f3
App Check App Attest: handle attestation rejection (#8170)
maksymmalyhin Jun 1, 2021
76486af
Add FIRAppAttestProvider.h the umbrella header
maksymmalyhin Jun 1, 2021
67c6d91
Add receivedAtDate property to the FAC token
maksymmalyhin Jun 2, 2021
a7c4792
Update tests to check receivedAtDate field where important
maksymmalyhin Jun 2, 2021
0317855
[WIP] Use FIRAppCheckTokenRefreshResult instead in the refresher API
maksymmalyhin Jun 3, 2021
e24afb9
Merge remote-tracking branch 'origin/master' into mm/appcheck-refresh
maksymmalyhin Jun 4, 2021
8c40b6d
[WIP] Fix refgresher usage
maksymmalyhin Jun 4, 2021
e0e570c
Update tests with new API, keep old logic
maksymmalyhin Jun 4, 2021
e30ba15
Merge remote-tracking branch 'origin/master' into mm/appcheck-refresh
maksymmalyhin Jun 7, 2021
6b846fc
Update tests with new logic
maksymmalyhin Jun 7, 2021
847fb98
WIP
maksymmalyhin Jun 7, 2021
813c671
WIP
maksymmalyhin Jun 8, 2021
5987d2e
Initial refresh tests and fixes.
maksymmalyhin Jun 9, 2021
8894e82
Add #import <TargetConditionals.h> where needed.
maksymmalyhin Jun 9, 2021
4391ce9
Formatting
maksymmalyhin Jun 9, 2021
93836e3
Cleanup and test updates
maksymmalyhin Jun 10, 2021
5276c56
style
maksymmalyhin Jun 10, 2021
40fc64b
Comments
maksymmalyhin Jun 10, 2021
5c312bc
Merge remote-tracking branch 'origin/master' into mm/appcheck-refresh
maksymmalyhin Jun 10, 2021
f4a7c7f
Cleanup and comments
maksymmalyhin Jun 10, 2021
a9812ca
Fix catalyst
maksymmalyhin Jun 10, 2021
4713d08
Changelog
maksymmalyhin Jun 10, 2021
9825b6f
Changelog version fix
maksymmalyhin Jun 11, 2021
3ec8edc
Typo
maksymmalyhin Jun 11, 2021
26241c6
Cleanup
maksymmalyhin Jun 11, 2021
f9d140d
Typo
maksymmalyhin Jun 11, 2021
d62661c
Merge branch 'mm/appcheck-refresh' of github.com:firebase/firebase-io…
maksymmalyhin Jun 11, 2021
c6aa5ca
Imports order
maksymmalyhin Jun 11, 2021
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests to check receivedAtDate field where important
  • Loading branch information
maksymmalyhin committed Jun 2, 2021
commit a7c47924e687cdcc47a42abd2027ec87ca2bd96f
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#import "FirebaseAppCheck/Sources/Core/APIService/FIRAppCheckToken+APIResponse.h"
#import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"

#if __has_include(<FBLPromises/FBLPromises.h>)
#import <FBLPromises/FBLPromises.h>
Expand Down Expand Up @@ -81,7 +82,7 @@ - (nullable instancetype)initWithResponseDict:(NSDictionary<NSString *, id> *)re

NSDate *expirationDate = [requestDate dateByAddingTimeInterval:secondsToLive];

return [self initWithToken:token expirationDate:expirationDate];
return [self initWithToken:token expirationDate:expirationDate receivedAtDate:requestDate];
}

@end
3 changes: 2 additions & 1 deletion FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
/// The designated initializer.
/// @param token A Firebase App Check token.
/// @param expirationDate A Firebase App Check token expiration date in the device local time.
/// @param receivedAtDate A date when the Firebase App Check token was received in the device's local time.
/// @param receivedAtDate A date when the Firebase App Check token was received in the device's
/// local time.
- (instancetype)initWithToken:(NSString *)token
expirationDate:(NSDate *)expirationDate
receivedAtDate:(NSDate *)receivedAtDate NS_DESIGNATED_INITIALIZER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ - (void)updateWithToken:(FIRAppCheckToken *)token {
}

- (FIRAppCheckToken *)appCheckToken {
return [[FIRAppCheckToken alloc] initWithToken:self.token expirationDate:self.expirationDate receivedAtDate:self.receivedAtDate];
return [[FIRAppCheckToken alloc] initWithToken:self.token
expirationDate:self.expirationDate
receivedAtDate:self.receivedAtDate];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ NS_SWIFT_NAME(AppCheckToken)
/// The default initializer.
/// @param token A Firebase App Check token.
/// @param expirationDate A Firebase App Check token expiration date in the device local time.
- (instancetype)initWithToken:(NSString *)token
expirationDate:(NSDate *)expirationDate;
- (instancetype)initWithToken:(NSString *)token expirationDate:(NSDate *)expirationDate;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "FirebaseAppCheck/Sources/Core/APIService/FIRAppCheckAPIService.h"
#import "FirebaseAppCheck/Sources/Core/Errors/FIRAppCheckErrorUtil.h"
#import "FirebaseAppCheck/Sources/Core/Errors/FIRAppCheckHTTPError.h"
#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckToken.h"
#import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"

#import "FirebaseAppCheck/Tests/Unit/Utils/FIRFixtureLoader.h"
#import "SharedTestUtilities/Date/FIRDateTestUtils.h"
Expand Down Expand Up @@ -224,7 +224,8 @@ - (void)testGetAppCheckTokenSuccess {
error:nil];
// 2.2. Return token from parsed response.
FIRAppCheckToken *expectedToken = [[FIRAppCheckToken alloc] initWithToken:@"app_check_token"
expirationDate:[NSDate date]];
expirationDate:[NSDate date]
receivedAtDate:[NSDate date]];
[self expectTokenWithAPIReponse:validAPIResponse toReturnToken:expectedToken];

// 3. Send request.
Expand All @@ -240,6 +241,7 @@ - (void)testGetAppCheckTokenSuccess {
XCTAssertEqualObjects(promise.value, expectedToken);
XCTAssertEqualObjects(promise.value.token, expectedToken.token);
XCTAssertEqualObjects(promise.value.expirationDate, expectedToken.expirationDate);
XCTAssertEqualObjects(promise.value.receivedAtDate, expectedToken.receivedAtDate);

OCMVerifyAll(self.mockAPIService);
}
Expand Down
9 changes: 6 additions & 3 deletions FirebaseAppCheck/Tests/Unit/Core/FIRAppCheckStorageTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#import <OCMock/OCMock.h>
#import "FBLPromise+Testing.h"

#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckToken.h"
#import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"

@interface FIRAppCheckStorageTests : XCTestCase
@property(nonatomic) NSString *appName;
Expand All @@ -47,7 +47,8 @@ - (void)tearDown {

- (void)testSetAndGetToken {
FIRAppCheckToken *tokenToStore = [[FIRAppCheckToken alloc] initWithToken:@"token"
expirationDate:[NSDate distantPast]];
expirationDate:[NSDate distantPast]
receivedAtDate:[NSDate date]];

FBLPromise *setPromise = [self.storage setToken:tokenToStore];
XCTAssert(FBLWaitForPromisesWithTimeout(0.5));
Expand All @@ -58,6 +59,7 @@ - (void)testSetAndGetToken {
XCTAssert(FBLWaitForPromisesWithTimeout(0.5));
XCTAssertEqualObjects(getPromise.value.token, tokenToStore.token);
XCTAssertEqualObjects(getPromise.value.expirationDate, tokenToStore.expirationDate);
XCTAssertEqualObjects(getPromise.value.receivedAtDate, tokenToStore.receivedAtDate);
XCTAssertNil(getPromise.error);
}

Expand All @@ -76,7 +78,8 @@ - (void)testRemoveToken {
- (void)testSetTokenPerApp {
// 1. Set token with a storage.
FIRAppCheckToken *tokenToStore = [[FIRAppCheckToken alloc] initWithToken:@"token"
expirationDate:[NSDate distantPast]];
expirationDate:[NSDate distantPast]
receivedAtDate:[NSDate date]];

FBLPromise *setPromise = [self.storage setToken:tokenToStore];
XCTAssert(FBLWaitForPromisesWithTimeout(0.5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#import <XCTest/XCTest.h>

#import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"
#import "FirebaseAppCheck/Sources/Core/Storage/FIRAppCheckStoredToken+FIRAppCheckToken.h"
#import "FirebaseAppCheck/Sources/Core/Storage/FIRAppCheckStoredToken.h"
#import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"

#import <GoogleUtilities/GULSecureCoding.h>

Expand Down Expand Up @@ -53,7 +53,8 @@ - (void)testSecureCoding {

- (void)testConvertingToAndFromFIRAppCheckToken {
FIRAppCheckToken *originalToken = [[FIRAppCheckToken alloc] initWithToken:@"___"
expirationDate:[NSDate date]];
expirationDate:[NSDate date]
receivedAtDate:[NSDate date]];

FIRAppCheckStoredToken *storedToken = [[FIRAppCheckStoredToken alloc] init];
[storedToken updateWithToken:originalToken];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#import <OCMock/OCMock.h>
#import "FBLPromise+Testing.h"

#import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"
#import "FirebaseAppCheck/Sources/DebugProvider/API/FIRAppCheckDebugProviderAPIService.h"
#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckDebugProvider.h"
#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckToken.h"

#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"

Expand Down Expand Up @@ -130,7 +130,8 @@ - (void)testGetTokenSuccess {
// 1. Stub API service.
NSString *expectedDebugToken = [self.provider currentDebugToken];
FIRAppCheckToken *validToken = [[FIRAppCheckToken alloc] initWithToken:@"valid_token"
expirationDate:[NSDate date]];
expirationDate:[NSDate date]
receivedAtDate:[NSDate date]];
OCMExpect([self.fakeAPIService appCheckTokenWithDebugToken:expectedDebugToken])
.andReturn([FBLPromise resolvedWith:validToken]);

Expand All @@ -139,6 +140,7 @@ - (void)testGetTokenSuccess {
XCTAssertNil(error);
XCTAssertEqualObjects(token.token, validToken.token);
XCTAssertEqualObjects(token.expirationDate, validToken.expirationDate);
XCTAssertEqualObjects(token.receivedAtDate, validToken.receivedAtDate);
}];

// 3. Verify fakes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#import <OCMock/OCMock.h>
#import "FBLPromise+Testing.h"

#import "FirebaseAppCheck/Sources/Core/FIRAppCheckToken+Internal.h"
#import "FirebaseAppCheck/Sources/DeviceCheckProvider/API/FIRDeviceCheckAPIService.h"
#import "FirebaseAppCheck/Sources/DeviceCheckProvider/FIRDeviceCheckTokenGenerator.h"
#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckToken.h"
#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRDeviceCheckProvider.h"

#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
Expand Down Expand Up @@ -90,7 +90,8 @@ - (void)testGetTokenSuccess {

// 2. Expect FAA token to be requested.
FIRAppCheckToken *validToken = [[FIRAppCheckToken alloc] initWithToken:@"valid_token"
expirationDate:[NSDate distantFuture]];
expirationDate:[NSDate distantFuture]
receivedAtDate:[NSDate date]];
OCMExpect([self.fakeAPIService appCheckTokenWithDeviceToken:deviceToken])
.andReturn([FBLPromise resolvedWith:validToken]);

Expand All @@ -102,6 +103,7 @@ - (void)testGetTokenSuccess {
[completionExpectation fulfill];
XCTAssertEqualObjects(token.token, validToken.token);
XCTAssertEqualObjects(token.expirationDate, validToken.expirationDate);
XCTAssertEqualObjects(token.receivedAtDate, validToken.receivedAtDate);
XCTAssertNil(error);
}];

Expand Down