Skip to content

Commit 032abb4

Browse files
author
renkelvin
authored
Recaptcha integration master pr (#11231)
1 parent 1efcabf commit 032abb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2286
-189
lines changed

FirebaseAuth.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ supports email and password accounts, as well as several 3rd party authenticatio
5757
s.dependency 'GoogleUtilities/AppDelegateSwizzler', '~> 7.8'
5858
s.dependency 'GoogleUtilities/Environment', '~> 7.8'
5959
s.dependency 'GTMSessionFetcher/Core', '>= 2.1', '< 4.0'
60-
60+
s.ios.dependency 'RecaptchaInterop', '~> 18.2.0'
6161
s.test_spec 'unit' do |unit_tests|
6262
unit_tests.scheme = { :code_coverage => true }
6363
# Unit tests can't run on watchOS.

FirebaseAuth/Sources/Auth/FIRAuth.m

Lines changed: 291 additions & 10 deletions
Large diffs are not rendered by default.

FirebaseAuth/Sources/Backend/FIRAuthBackend+MultiFactor.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ @implementation FIRAuthBackend (MultiFactor)
2424
+ (void)startMultiFactorEnrollment:(FIRStartMFAEnrollmentRequest *)request
2525
callback:(FIRStartMFAEnrollmentResponseCallback)callback {
2626
FIRStartMFAEnrollmentResponse *response = [[FIRStartMFAEnrollmentResponse alloc] init];
27-
[[self implementation] postWithRequest:request
27+
[[self implementation] callWithRequest:request
2828
response:response
2929
callback:^(NSError *error) {
3030
if (error) {
@@ -38,7 +38,7 @@ + (void)startMultiFactorEnrollment:(FIRStartMFAEnrollmentRequest *)request
3838
+ (void)finalizeMultiFactorEnrollment:(FIRFinalizeMFAEnrollmentRequest *)request
3939
callback:(FIRFinalizeMFAEnrollmentResponseCallback)callback {
4040
FIRFinalizeMFAEnrollmentResponse *response = [[FIRFinalizeMFAEnrollmentResponse alloc] init];
41-
[[self implementation] postWithRequest:request
41+
[[self implementation] callWithRequest:request
4242
response:response
4343
callback:^(NSError *error) {
4444
if (error) {
@@ -52,7 +52,7 @@ + (void)finalizeMultiFactorEnrollment:(FIRFinalizeMFAEnrollmentRequest *)request
5252
+ (void)startMultiFactorSignIn:(FIRStartMFASignInRequest *)request
5353
callback:(FIRStartMFASignInResponseCallback)callback {
5454
FIRStartMFASignInResponse *response = [[FIRStartMFASignInResponse alloc] init];
55-
[[self implementation] postWithRequest:request
55+
[[self implementation] callWithRequest:request
5656
response:response
5757
callback:^(NSError *error) {
5858
if (error) {
@@ -66,7 +66,7 @@ + (void)startMultiFactorSignIn:(FIRStartMFASignInRequest *)request
6666
+ (void)finalizeMultiFactorSignIn:(FIRFinalizeMFASignInRequest *)request
6767
callback:(FIRFinalizeMFASignInResponseCallback)callback {
6868
FIRFinalizeMFASignInResponse *response = [[FIRFinalizeMFASignInResponse alloc] init];
69-
[[self implementation] postWithRequest:request
69+
[[self implementation] callWithRequest:request
7070
response:response
7171
callback:^(NSError *error) {
7272
if (error) {
@@ -80,7 +80,7 @@ + (void)finalizeMultiFactorSignIn:(FIRFinalizeMFASignInRequest *)request
8080
+ (void)withdrawMultiFactor:(FIRWithdrawMFARequest *)request
8181
callback:(FIRWithdrawMFAResponseCallback)callback {
8282
FIRWithdrawMFAResponse *response = [[FIRWithdrawMFAResponse alloc] init];
83-
[[self implementation] postWithRequest:request
83+
[[self implementation] callWithRequest:request
8484
response:response
8585
callback:^(NSError *error) {
8686
if (error) {

FirebaseAuth/Sources/Backend/FIRAuthBackend.h

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
@class FIRSignUpNewUserResponse;
5757
@class FIRRevokeTokenRequest;
5858
@class FIRRevokeTokenResponse;
59+
@class FIRGetRecaptchaConfigRequest;
60+
@class FIRGetRecaptchaConfigResponse;
5961

6062
@protocol FIRAuthBackendImplementation;
6163
@protocol FIRAuthBackendRPCIssuer;
@@ -241,6 +243,15 @@ typedef void (^FIRRevokeTokenResponseCallback)(FIRRevokeTokenResponse *_Nullable
241243
typedef void (^FIRSignInWithGameCenterResponseCallback)(
242244
FIRSignInWithGameCenterResponse *_Nullable response, NSError *_Nullable error);
243245

246+
/** @typedef FIRGetRecaptchaConfigResponseCallback
247+
@brief The type of block used to return the result of a call to the getRecaptchaConfig endpoint.
248+
@param response The received response, if any.
249+
@param error The error which occurred, if any.
250+
@remarks One of response or error will be non-nil.
251+
*/
252+
typedef void (^FIRGetRecaptchaConfigResponseCallback)(
253+
FIRGetRecaptchaConfigResponse *_Nullable response, NSError *_Nullable error);
254+
244255
/** @class FIRAuthBackend
245256
@brief Simple static class with methods representing the backend RPCs.
246257
@remarks All callback blocks passed as method parameters are invoked asynchronously on the
@@ -398,6 +409,15 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
398409
+ (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
399410
callback:(FIRSignInWithGameCenterResponseCallback)callback;
400411

412+
/** @fn getRecaptchaConfig:callback:
413+
@brief Calls the getRecaptchaConfig endpoint, which is responsible for retrieving the recaptcha
414+
configs including site key, provider enablement status.
415+
@param request The request parameters.
416+
@param callback The callback.
417+
*/
418+
+ (void)getRecaptchaConfig:(FIRGetRecaptchaConfigRequest *)request
419+
callback:(FIRGetRecaptchaConfigResponseCallback)callback;
420+
401421
#if TARGET_OS_IOS
402422
/** @fn sendVerificationCode:callback:
403423
@brief Calls the sendVerificationCode endpoint, which is responsible for sending the
@@ -444,16 +464,16 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
444464
*/
445465
@protocol FIRAuthBackendRPCIssuer <NSObject>
446466

447-
/** @fn asyncPostToURLWithRequestConfiguration:URL:body:contentType:completionHandler:
448-
@brief Asynchronously seXnds a POST request.
467+
/** @fn asyncCallToURLWithRequestConfiguration:URL:body:contentType:completionHandler:
468+
@brief Asynchronously sends a HTTP request.
449469
@param requestConfiguration The request to be made.
450470
@param URL The request URL.
451471
@param body Request body.
452472
@param contentType Content type of the body.
453-
@param handler provided that handles POST response. Invoked asynchronously on the auth global
473+
@param handler provided that handles HTTP response. Invoked asynchronously on the auth global
454474
work queue in the future.
455475
*/
456-
- (void)asyncPostToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
476+
- (void)asyncCallToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
457477
URL:(NSURL *)URL
458478
body:(nullable NSData *)body
459479
contentType:(NSString *)contentType
@@ -620,6 +640,15 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
620640
- (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
621641
callback:(FIRSignInWithGameCenterResponseCallback)callback;
622642

643+
/** @fn getRecaptchaConfig:callback:
644+
@brief Calls the getRecaptchaConfig endpoint, which is responsible for retrieving the recaptcha
645+
configs including site key, provider enablement status.
646+
@param request The request parameters.
647+
@param callback The callback.
648+
*/
649+
- (void)getRecaptchaConfig:(FIRGetRecaptchaConfigRequest *)request
650+
callback:(FIRGetRecaptchaConfigResponseCallback)callback;
651+
623652
/** @fn resetPassword:callback
624653
@brief Calls the resetPassword endpoint, which is responsible for resetting a user's password
625654
given an OOB code and new password.
@@ -629,8 +658,8 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
629658
- (void)resetPassword:(FIRResetPasswordRequest *)request
630659
callback:(FIRResetPasswordCallback)callback;
631660

632-
/** @fn postWithRequest:response:callback:
633-
@brief Calls the RPC using HTTP POST.
661+
/** @fn callWithRequest:response:callback:
662+
@brief Calls the RPC using HTTP request.
634663
@remarks Possible error responses:
635664
@see FIRAuthInternalErrorCodeRPCRequestEncodingError
636665
@see FIRAuthInternalErrorCodeJSONSerializationError
@@ -642,7 +671,7 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
642671
@param response The empty response to be filled.
643672
@param callback The callback for both success and failure.
644673
*/
645-
- (void)postWithRequest:(id<FIRAuthRPCRequest>)request
674+
- (void)callWithRequest:(id<FIRAuthRPCRequest>)request
646675
response:(id<FIRAuthRPCResponse>)response
647676
callback:(void (^)(NSError *_Nullable error))callback;
648677

0 commit comments

Comments
 (0)