Skip to content

Commit 0003438

Browse files
committed
Merge pull request #232 from ParsePlatform/nlutsenko.authProviders
Publicize Third Party Authentication methods.
2 parents 5117f83 + 8ecc87c commit 0003438

File tree

7 files changed

+120
-77
lines changed

7 files changed

+120
-77
lines changed

Parse.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
810ECC7E1B573D28002944D4 /* PFTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 810ECC791B573D28002944D4 /* PFTestCase.m */; };
3535
810ECC7F1B573D28002944D4 /* PFUnitTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 810ECC7C1B573D28002944D4 /* PFUnitTestCase.m */; };
3636
810ECC801B573D28002944D4 /* PFUnitTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 810ECC7C1B573D28002944D4 /* PFUnitTestCase.m */; };
37+
811083F21BA2580100FC7F65 /* PFAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 811083F11BA2580100FC7F65 /* PFAuthenticationProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
38+
811083F31BA2580100FC7F65 /* PFAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 811083F11BA2580100FC7F65 /* PFAuthenticationProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
3739
811214731B3E1CF10052741B /* PFObjectBatchController.h in Headers */ = {isa = PBXBuildFile; fileRef = 811214711B3E1CF10052741B /* PFObjectBatchController.h */; };
3840
811214741B3E1CF10052741B /* PFObjectBatchController.h in Headers */ = {isa = PBXBuildFile; fileRef = 811214711B3E1CF10052741B /* PFObjectBatchController.h */; };
3941
811214751B3E1CF10052741B /* PFObjectBatchController.m in Sources */ = {isa = PBXBuildFile; fileRef = 811214721B3E1CF10052741B /* PFObjectBatchController.m */; };
@@ -458,8 +460,6 @@
458460
8166FCE01B503914003841A2 /* PFAnonymousAuthenticationProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 8166FCD61B503914003841A2 /* PFAnonymousAuthenticationProvider.m */; };
459461
8166FCE11B503914003841A2 /* PFAnonymousUtils_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8166FCD71B503914003841A2 /* PFAnonymousUtils_Private.h */; };
460462
8166FCE21B503914003841A2 /* PFAnonymousUtils_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8166FCD71B503914003841A2 /* PFAnonymousUtils_Private.h */; };
461-
8166FCE31B503914003841A2 /* PFAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8166FCD81B503914003841A2 /* PFAuthenticationProvider.h */; };
462-
8166FCE41B503914003841A2 /* PFAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8166FCD81B503914003841A2 /* PFAuthenticationProvider.h */; };
463463
8166FCE81B504083003841A2 /* PFPushManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 8166FCE61B504083003841A2 /* PFPushManager.h */; };
464464
8166FCE91B504083003841A2 /* PFPushManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 8166FCE61B504083003841A2 /* PFPushManager.h */; };
465465
8166FCEA1B504083003841A2 /* PFPushManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8166FCE71B504083003841A2 /* PFPushManager.m */; };
@@ -1098,6 +1098,7 @@
10981098
810ECC791B573D28002944D4 /* PFTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFTestCase.m; sourceTree = "<group>"; };
10991099
810ECC7B1B573D28002944D4 /* PFUnitTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFUnitTestCase.h; sourceTree = "<group>"; };
11001100
810ECC7C1B573D28002944D4 /* PFUnitTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFUnitTestCase.m; sourceTree = "<group>"; };
1101+
811083F11BA2580100FC7F65 /* PFAuthenticationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFAuthenticationProvider.h; sourceTree = "<group>"; };
11011102
811214711B3E1CF10052741B /* PFObjectBatchController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFObjectBatchController.h; sourceTree = "<group>"; };
11021103
811214721B3E1CF10052741B /* PFObjectBatchController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFObjectBatchController.m; sourceTree = "<group>"; };
11031104
81146C7C1A785203001F8473 /* PFRESTObjectCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFRESTObjectCommand.h; sourceTree = "<group>"; };
@@ -1322,7 +1323,6 @@
13221323
8166FCD51B503914003841A2 /* PFAnonymousAuthenticationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFAnonymousAuthenticationProvider.h; sourceTree = "<group>"; };
13231324
8166FCD61B503914003841A2 /* PFAnonymousAuthenticationProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFAnonymousAuthenticationProvider.m; sourceTree = "<group>"; };
13241325
8166FCD71B503914003841A2 /* PFAnonymousUtils_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFAnonymousUtils_Private.h; sourceTree = "<group>"; };
1325-
8166FCD81B503914003841A2 /* PFAuthenticationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFAuthenticationProvider.h; sourceTree = "<group>"; };
13261326
8166FCE61B504083003841A2 /* PFPushManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFPushManager.h; sourceTree = "<group>"; };
13271327
8166FCE71B504083003841A2 /* PFPushManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFPushManager.m; sourceTree = "<group>"; };
13281328
816AC9B81A3F48250031D94C /* PFApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFApplication.h; sourceTree = "<group>"; };
@@ -1610,6 +1610,7 @@
16101610
9739513916B9D28E0010B884 /* PFAnalytics.m */,
16111611
638CBBB415191435004F54E4 /* PFAnonymousUtils.h */,
16121612
638CBBB515191435004F54E4 /* PFAnonymousUtils.m */,
1613+
811083F11BA2580100FC7F65 /* PFAuthenticationProvider.h */,
16131614
805D3D9F15E31241007E8D10 /* PFCloud.h */,
16141615
805D3DA015E31241007E8D10 /* PFCloud.m */,
16151616
81EB6632198A7FA600851598 /* PFConfig.h */,
@@ -2459,7 +2460,6 @@
24592460
isa = PBXGroup;
24602461
children = (
24612462
8166FCD41B503914003841A2 /* Anonymous */,
2462-
8166FCD81B503914003841A2 /* PFAuthenticationProvider.h */,
24632463
);
24642464
path = Providers;
24652465
sourceTree = "<group>";
@@ -3138,6 +3138,7 @@
31383138
810749AE1B74662B00682EEB /* PFURLSessionFileDownloadTaskDelegate.h in Headers */,
31393139
F5B0B2FC1B449F1D00F3EBC4 /* PFInternalUtils.h in Headers */,
31403140
F5B0B2FD1B449F1D00F3EBC4 /* PFKeychainStore.h in Headers */,
3141+
811083F21BA2580100FC7F65 /* PFAuthenticationProvider.h in Headers */,
31413142
818D58731B5DAAFE00813989 /* PFCommandRunningConstants.h in Headers */,
31423143
F5B0B2FF1B449F1D00F3EBC4 /* PFMulticastDelegate.h in Headers */,
31433144
81C6BDF41B4DD32700553A83 /* PFCurrentObjectControlling.h in Headers */,
@@ -3170,7 +3171,6 @@
31703171
8166FC5E1B503755003841A2 /* PFObjectPrivate.h in Headers */,
31713172
8166FC831B503794003841A2 /* PFInstallationIdentifierStore.h in Headers */,
31723173
81BCB4CA1B744626006659CB /* PFURLSessionJSONDataTaskDelegate.h in Headers */,
3173-
8166FCE31B503914003841A2 /* PFAuthenticationProvider.h in Headers */,
31743174
814BCDF71B4DF66500007B7F /* PFMutableUserState.h in Headers */,
31753175
815EE92319F989380076FE5D /* PFRESTConfigCommand.h in Headers */,
31763176
81C9C9F719FEA89200D514C5 /* PFRESTPushCommand.h in Headers */,
@@ -3363,6 +3363,7 @@
33633363
F5B0B3461B44A33200F3EBC4 /* PFPushState.h in Headers */,
33643364
F5B0B3471B44A33200F3EBC4 /* PFPushState_Private.h in Headers */,
33653365
812B63011B5F30D3009CEAA9 /* PFObjectFileCoder.h in Headers */,
3366+
811083F31BA2580100FC7F65 /* PFAuthenticationProvider.h in Headers */,
33663367
F5B0B3481B44A33200F3EBC4 /* PFMutablePushState.h in Headers */,
33673368
F5B0B3491B44A33200F3EBC4 /* PFPushController.h in Headers */,
33683369
F5B0B34A1B44A33200F3EBC4 /* PFPushChannelsController.h in Headers */,
@@ -3402,7 +3403,6 @@
34023403
81C7F4A31AF4220A007B5418 /* PFMutableFileState.h in Headers */,
34033404
810B7D771A0291FF003C0909 /* PFMacros.h in Headers */,
34043405
81C6BDEF1B4DB16500553A83 /* PFInstallationConstants.h in Headers */,
3405-
8166FCE41B503914003841A2 /* PFAuthenticationProvider.h in Headers */,
34063406
F51535061B57240900C49F56 /* PFACLState.h in Headers */,
34073407
8166FC9B1B503830003841A2 /* PFSession_Private.h in Headers */,
34083408
81F0E89619E6F83E00812A88 /* PFGeoPoint.h in Headers */,

Parse/Internal/User/AuthenticationProviders/Providers/PFAuthenticationProvider.h

Lines changed: 0 additions & 49 deletions
This file was deleted.

Parse/Internal/User/PFUserPrivate.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,7 @@ extern NSString *const PFUserCurrentUserKeychainItemName;
7171
- (BFTask *)_logOutAsync;
7272

7373
///--------------------------------------
74-
/// @name Authentication Providers
75-
///--------------------------------------
76-
77-
// TODO: (nlutsenko) Add Documentation
78-
+ (void)registerAuthenticationProvider:(id<PFAuthenticationProvider>)authenticationProvider;
79-
80-
// TODO: (nlutsenko) Add Documentation
81-
+ (BFTask *)logInWithAuthTypeInBackground:(NSString *)authType authData:(NSDictionary *)authData;
82-
83-
// TODO: (nlutsenko) Add Documentation
84-
- (BFTask *)linkWithAuthTypeInBackground:(NSString *)authType authData:(NSDictionary *)authData;
85-
86-
// TODO: (nlutsenko) Add Documentation
87-
- (BFTask *)unlinkWithAuthTypeInBackground:(NSString *)authType;
88-
89-
// TODO: (nlutsenko) Add Documentation
90-
- (BOOL)isLinkedWithAuthType:(NSString *)authType;
91-
92-
///--------------------------------------
93-
/// @name Authentication Providers (Private)
74+
/// @name Third-party Authentication (Private)
9475
///--------------------------------------
9576

9677
+ (void)_unregisterAuthenticationProvider:(id<PFAuthenticationProvider>)provider;

Parse/PFAuthenticationProvider.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Copyright (c) 2015-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import <Foundation/Foundation.h>
11+
12+
#import <Bolts/BFTask.h>
13+
14+
#import <Parse/PFConstants.h>
15+
16+
PF_ASSUME_NONNULL_BEGIN
17+
18+
/*!
19+
Provides a general interface for delegation of third party authentication with <PFUser>s.
20+
*/
21+
@protocol PFAuthenticationProvider <NSObject>
22+
23+
/*!
24+
@returns Returns a unique name for the type of authentication the provider does.
25+
*/
26+
+ (NSString *)authType;
27+
28+
/*!
29+
@abstract Deauthenticates (logs out) the user associated with this provider.
30+
31+
@returns A task that resolves to anything if deauthentication succeeded, otherwise - faulted task.
32+
*/
33+
- (BFTask *)deauthenticateInBackground;
34+
35+
/*!
36+
@abstract Restores authenticaiton that has been serialized, such as session keys, etc.
37+
38+
@param authData The auth data for the provider. This value may be `nil` when unlinking an account.
39+
40+
@returns A task that resolves to anything if authenticaiton restoration succeeded, otherwise - faulted task.
41+
*/
42+
- (BFTask *)restoreAuthenticationInBackgroundWithAuthData:(PF_NULLABLE NSDictionary *)authData;
43+
44+
@end
45+
46+
PF_ASSUME_NONNULL_END

Parse/PFUser.h

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ PF_ASSUME_NONNULL_BEGIN
2020
typedef void(^PFUserSessionUpgradeResultBlock)(NSError *PF_NULLABLE_S error);
2121
typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);
2222

23-
2423
@class PFQuery;
24+
@protocol PFAuthenticationProvider;
2525

2626
/*!
2727
The `PFUser` class is a local representation of a user persisted to the Parse Data.
@@ -449,6 +449,70 @@ typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);
449449
target:(PF_NULLABLE_S id)target
450450
selector:(PF_NULLABLE_S SEL)selector;
451451

452+
///--------------------------------------
453+
/// @name Third-party Authentication
454+
///--------------------------------------
455+
456+
/*!
457+
@abstract Registers a tuhrd party authentication provider.
458+
459+
@note This method shouldn't be invoked directly unless developing a third party authentication provider.
460+
@see PFAuthenticationProvider
461+
462+
@param authenticationProvider The third party authenticaiton provider to be registered.
463+
*/
464+
+ (void)registerAuthenticationProvider:(id<PFAuthenticationProvider>)authenticationProvider;
465+
466+
/*!
467+
@abstract Logs in a user with third party authentication credentials.
468+
469+
@note This method shouldn't be invoked directly unless developing a third party authentication provider.
470+
@see PFAuthenticationProvider
471+
472+
@param authType The name of the type of third party authenticaiton provider.
473+
@param authData The user credentials of the third party authentication provider.
474+
475+
@returns A `BFTask` that is resolved to `PFUser` when logging in completes.
476+
*/
477+
+ (BFTask PF_GENERIC(PFUser *) *)logInWithAuthTypeInBackground:(NSString *)authType authData:(NSDictionary *)authData;
478+
479+
/*!
480+
@abstract Links this user to a third party authentication provider.
481+
482+
@note This method shouldn't be invoked directly unless developing a third party authentication provider.
483+
@see PFAuthenticationProvider
484+
485+
@param authType The name of the type of third party authenticaiton provider.
486+
@param authData The user credentials of the third party authentication provider.
487+
488+
@returns A `BFTask` that is resolved to `@YES` if linking succeeds.
489+
*/
490+
- (BFTask PF_GENERIC(NSNumber *) *)linkWithAuthTypeInBackground:(NSString *)authType authData:(NSDictionary *)authData;
491+
492+
/*!
493+
@abstract Unlinks this user from a third party authentication provider.
494+
495+
@note This method shouldn't be invoked directly unless developing a third party authentication provider.
496+
@see PFAuthenticationProvider
497+
498+
@param authType The name of the type of third party authenticaiton provider.
499+
500+
@returns A `BFTask` that is resolved to `@YES` if unlinking succeeds.
501+
*/
502+
- (BFTask PF_GENERIC(NSNumber *) *)unlinkWithAuthTypeInBackground:(NSString *)authType;
503+
504+
/*!
505+
@abstract Indicates whether this user is linked with a third party authentication provider of a specific type.
506+
507+
@note This method shouldn't be invoked directly unless developing a third party authentication provider.
508+
@see PFAuthenticationProvider
509+
510+
@param authType The name of the type of third party authenticaiton provider.
511+
512+
@returns `YES` if the user is linked with a provider, otherwise `NO`.
513+
*/
514+
- (BOOL)isLinkedWithAuthType:(NSString *)authType;
515+
452516
@end
453517

454518
PF_ASSUME_NONNULL_END

Parse/PFUser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ + (void)logInWithUsernameInBackground:(NSString *)username
812812
}
813813

814814
///--------------------------------------
815-
#pragma mark - Authentication Providers
815+
#pragma mark - Third-party Authentication
816816
///--------------------------------------
817817

818818
+ (void)registerAuthenticationProvider:(id<PFAuthenticationProvider>)authenticationProvider {

Parse/Parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import <Parse/PFACL.h>
1313
#import <Parse/PFAnalytics.h>
1414
#import <Parse/PFAnonymousUtils.h>
15+
#import <Parse/PFAuthenticationProvider.h>
1516
#import <Parse/PFCloud.h>
1617
#import <Parse/PFConfig.h>
1718
#import <Parse/PFConstants.h>

0 commit comments

Comments
 (0)