-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Implemented finalizePasskeyEnrollment rpc call
2. Defined finalizePasskeyEnrollment Request and Response object 3. Added unit tests
- Loading branch information
1 parent
b8f0972
commit a1143f7
Showing
9 changed files
with
729 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
FirebaseAuth/Sources/Backend/RPC/FIRFinalizePasskeyEnrollmentRequest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h" | ||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h" | ||
#import <AuthenticationServices/ASAuthorizationPlatformPublicKeyCredentialRegistration.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** @class FIRFinalizePasskeyEnrollmentRequest | ||
@brief Represents the parameters for the finalizePasskeyEnrollment endpoint. | ||
*/ | ||
@interface FIRFinalizePasskeyEnrollmentRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest> | ||
|
||
/** | ||
@property IDToken | ||
@brief The raw user access token. | ||
*/ | ||
@property(nonatomic, copy, readonly) NSString *IDToken; | ||
|
||
/** | ||
@property name | ||
@brief The passkey name. | ||
*/ | ||
@property(nonatomic, copy, readonly) NSString *name; | ||
|
||
/** | ||
@property credentialID | ||
@brief The credential ID. | ||
*/ | ||
@property(nonatomic, copy, readonly) NSString *credentialID; | ||
|
||
/** | ||
@property clientDataJson | ||
@brief The CollectedClientData object from the authenticator. | ||
*/ | ||
@property(nonatomic, copy, readonly) NSString *clientDataJson; | ||
|
||
/** | ||
@property attestationObject | ||
@brief The attestation object from the authenticator. | ||
*/ | ||
@property(nonatomic, copy, readonly) NSString *attestationObject; | ||
|
||
- (nullable instancetype)initWithIDToken:(NSString *)IDToken | ||
name:(NSString *)name | ||
credentialID:(NSString *)credentialID | ||
clientDataJson:(NSString *)clientDataJson | ||
attestationObject:(NSString *)attestationObject | ||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
127 changes: 127 additions & 0 deletions
127
FirebaseAuth/Sources/Backend/RPC/FIRFinalizePasskeyEnrollmentRequest.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "FirebaseAuth/Sources/Backend/RPC/FIRFinalizePasskeyEnrollmentRequest.h" | ||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
@var kFinalizePasskeyEnrollmentEndPoint | ||
@brief GCIP endpoint for finalizePasskeyEnrollment rpc | ||
*/ | ||
static NSString *const kFinalizePasskeyEnrollmentEndPoint = @"accounts/passkeyEnrollment:finalize"; | ||
|
||
/** | ||
@var kTenantIDKey | ||
@brief The key for the tenant id value in the request. | ||
*/ | ||
static NSString *const kTenantIDKey = @"tenantId"; | ||
|
||
/** | ||
@var kIDTokenKey | ||
@brief The key for idToken value in the request. | ||
*/ | ||
static NSString *const kIDTokenKey = @"idToken"; | ||
|
||
/** | ||
@var kAuthRegistrationRespKey | ||
@brief The key for registration object from the authenticator. | ||
*/ | ||
static NSString *const kAuthRegistrationRespKey = @"authenticatorRegistrationResponse"; | ||
|
||
/** | ||
@var kNameKey | ||
@brief The key of passkey name. | ||
*/ | ||
static NSString *const kNameKey = @"name"; | ||
|
||
/** | ||
@var kCredentialIDKey | ||
@brief The key for registered credential identifier. | ||
*/ | ||
static NSString *const kCredentialIDKey = @"credentialId"; | ||
|
||
/** | ||
@var kAuthAttestationRespKey | ||
@brief The key for attestation response from a FIDO authenticator. | ||
*/ | ||
static NSString *const kAuthAttestationRespKey = @"authenticatorAttestationResponse"; | ||
|
||
/** | ||
@var kClientDataJsonKey | ||
@brief The key for CollectedClientData object from the authenticator. | ||
*/ | ||
static NSString *const kClientDataJsonKey = @"clientDataJson"; | ||
|
||
/** | ||
@var kAttestationObject | ||
@brief The key for the attestation object from the authenticator. | ||
*/ | ||
static NSString *const kAttestationObject = @"attestationObject"; | ||
|
||
|
||
@implementation FIRFinalizePasskeyEnrollmentRequest | ||
|
||
- (nullable instancetype)initWithIDToken:(NSString *)IDToken | ||
name:(NSString *)name | ||
credentialID:(NSString *)credentialID | ||
clientDataJson:(NSString *)clientDataJson | ||
attestationObject:(NSString *)attestationObject requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { | ||
self = [super initWithEndpoint:kFinalizePasskeyEnrollmentEndPoint | ||
requestConfiguration:requestConfiguration]; | ||
if (self) { | ||
self.useIdentityPlatform = YES; | ||
_IDToken = IDToken; | ||
_name = name; | ||
_credentialID = credentialID; | ||
_clientDataJson = clientDataJson; | ||
_attestationObject = attestationObject; | ||
} | ||
return self; | ||
} | ||
|
||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *__autoreleasing _Nullable *)error { | ||
NSMutableDictionary *postBody = [NSMutableDictionary dictionary]; | ||
NSMutableDictionary *authRegistrationResponse = [NSMutableDictionary dictionary]; | ||
NSMutableDictionary *authAttestationResponse = [NSMutableDictionary dictionary]; | ||
|
||
if (_IDToken) { | ||
postBody[kIDTokenKey] = _IDToken; | ||
} | ||
if (_name) { | ||
postBody[kNameKey] = _name; | ||
} | ||
if (_credentialID) { | ||
authRegistrationResponse[kCredentialIDKey] = _credentialID; | ||
} | ||
if (_clientDataJson) { | ||
authAttestationResponse[kClientDataJsonKey] = _clientDataJson; | ||
} | ||
if (_attestationObject) { | ||
authAttestationResponse[kAttestationObject] = _attestationObject; | ||
} | ||
if (self.tenantID) { | ||
postBody[kTenantIDKey] = self.tenantID; | ||
} | ||
|
||
authRegistrationResponse[kAuthAttestationRespKey] = authAttestationResponse; | ||
postBody[kAuthRegistrationRespKey] = authRegistrationResponse; | ||
|
||
return [postBody copy]; | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
41 changes: 41 additions & 0 deletions
41
FirebaseAuth/Sources/Backend/RPC/FIRFinalizePasskeyEnrollmentResponse.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
@class FIRFinalizePasskeyEnrollmentResponse | ||
@brief Represents the response from the startPasskeyEnrollment endpoint. | ||
*/ | ||
@interface FIRFinalizePasskeyEnrollmentResponse : NSObject <FIRAuthRPCResponse> | ||
|
||
/** | ||
@property idToken | ||
@brief The user raw access token. | ||
*/ | ||
@property(nonatomic, readonly, copy) NSString *idToken; | ||
|
||
/** | ||
@property refershToken | ||
@brief Refresh token for the authenticated user. | ||
*/ | ||
@property(nonatomic, copy, readonly) NSData *refreshToken; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.