Skip to content

Commit b5d0a0d

Browse files
author
Chuan Ren
committed
Revert "Implement oauth secret token in headful-lite. (#2663)"
This reverts commit b30d005. # Conflicts: # Firebase/Auth/Source/Public/FIRTwitterAuthProvider.h
1 parent a5a459e commit b5d0a0d

16 files changed

+32
-118
lines changed

Example/Auth/Tests/FIRUserTests.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,7 @@ - (void)testlinkAndRetrieveDataError {
15151515
FIRVerifyAssertionResponseCallback callback) {
15161516
dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
15171517
callback(nil,
1518-
[FIRAuthErrorUtils accountExistsWithDifferentCredentialErrorWithEmail:kEmail
1519-
updatedCredential:nil]);
1518+
[FIRAuthErrorUtils accountExistsWithDifferentCredentialErrorWithEmail:kEmail]);
15201519
});
15211520
});
15221521

Firebase/Auth/Source/Auth/FIRAuth.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,12 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
841841
requestConfiguration:_requestConfiguration];
842842
request.autoCreate = !isReauthentication;
843843
[credential prepareVerifyAssertionRequest:request];
844+
if ([credential isKindOfClass:[FIROAuthCredential class]]) {
845+
FIROAuthCredential *OAuthCredential = (FIROAuthCredential *)credential;
846+
request.requestURI = OAuthCredential.OAuthResponseURLString;
847+
request.sessionID = OAuthCredential.sessionID;
848+
request.pendingToken = OAuthCredential.pendingToken;
849+
}
844850
[FIRAuthBackend verifyAssertion:request
845851
callback:^(FIRVerifyAssertionResponse *response, NSError *error) {
846852
if (error) {
@@ -853,10 +859,7 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
853859
if (response.needConfirmation) {
854860
if (callback) {
855861
NSString *email = response.email;
856-
FIROAuthCredential *credential =
857-
[[FIROAuthCredential alloc] initWithVerifyAssertionResponse:response];
858-
callback(nil, [FIRAuthErrorUtils accountExistsWithDifferentCredentialErrorWithEmail:email
859-
updatedCredential:credential]);
862+
callback(nil, [FIRAuthErrorUtils accountExistsWithDifferentCredentialErrorWithEmail:email]);
860863
}
861864
return;
862865
}
@@ -875,12 +878,9 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
875878
if (callback) {
876879
FIRAdditionalUserInfo *additionalUserInfo =
877880
[FIRAdditionalUserInfo userInfoWithVerifyAssertionResponse:response];
878-
FIROAuthCredential *updatedOAuthCredential =
879-
[[FIROAuthCredential alloc] initWithVerifyAssertionResponse:response];
880881
FIRAuthDataResult *result = user ?
881882
[[FIRAuthDataResult alloc] initWithUser:user
882-
additionalUserInfo:additionalUserInfo
883-
credential:updatedOAuthCredential] : nil;
883+
additionalUserInfo:additionalUserInfo] : nil;
884884
callback(result, error);
885885
}
886886
}];

Firebase/Auth/Source/Auth/FIRAuthDataResult.m

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#import "FIRAdditionalUserInfo.h"
2020
#import "FIRUser.h"
21-
#import "FIROAuthCredential.h"
2221

2322
NS_ASSUME_NONNULL_BEGIN
2423

@@ -34,24 +33,12 @@ @implementation FIRAuthDataResult
3433
*/
3534
static NSString *const kUserCodingKey = @"user";
3635

37-
/** @var kCredentialCodingKey
38-
@brief The key used to encode the credential for NSSecureCoding.
39-
*/
40-
static NSString *const kCredentialCodingKey = @"credential";
41-
4236
- (nullable instancetype)initWithUser:(nullable FIRUser *)user
4337
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo {
44-
return [self initWithUser:user additionalUserInfo:additionalUserInfo credential:nil];
45-
}
46-
47-
- (nullable instancetype)initWithUser:(nullable FIRUser *)user
48-
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo
49-
credential:(nullable FIROAuthCredential *)credential {
5038
self = [super init];
5139
if (self) {
5240
_additionalUserInfo = additionalUserInfo;
5341
_user = user;
54-
_credential = credential;
5542
}
5643
return self;
5744
}
@@ -68,16 +55,13 @@ - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
6855
FIRAdditionalUserInfo *additionalUserInfo =
6956
[aDecoder decodeObjectOfClass:[FIRAdditionalUserInfo class]
7057
forKey:kAdditionalUserInfoCodingKey];
71-
FIROAuthCredential *credential =
72-
[aDecoder decodeObjectOfClass:[FIROAuthCredential class]
73-
forKey:kCredentialCodingKey];
74-
return [self initWithUser:user additionalUserInfo:additionalUserInfo credential:credential];
58+
59+
return [self initWithUser:user additionalUserInfo:additionalUserInfo];
7560
}
7661

7762
- (void)encodeWithCoder:(NSCoder *)aCoder {
7863
[aCoder encodeObject:_user forKey:kUserCodingKey];
7964
[aCoder encodeObject:_additionalUserInfo forKey:kAdditionalUserInfoCodingKey];
80-
[aCoder encodeObject:_credential forKey:kCredentialCodingKey];
8165
}
8266

8367
@end

Firebase/Auth/Source/Auth/FIRAuthDataResult_Internal.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
2525
@param user The signed in user reference.
2626
@param additionalUserInfo The additional user info if available.
2727
*/
28-
- (nullable instancetype)initWithUser:(nullable FIRUser *)user
29-
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo;
30-
31-
/** @fn initWithUser:additionalUserInfo:
32-
@brief Designated initializer.
33-
@param user The signed in user reference.
34-
@param additionalUserInfo The additional user info if available.
35-
@param credential The updated OAuth credential if available.
36-
*/
3728
- (nullable instancetype)initWithUser:(nullable FIRUser *)user
3829
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo
39-
credential:(nullable FIROAuthCredential *)credential
4030
NS_DESIGNATED_INITIALIZER;
4131

4232
@end

Firebase/Auth/Source/AuthProvider/OAuth/FIROAuthCredential.m

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#import "FIRAuthExceptionUtils.h"
2121
#import "FIROAuthCredential_Internal.h"
2222
#import "FIRVerifyAssertionRequest.h"
23-
#import "FIRVerifyAssertionResponse.h"
2423

2524
NS_ASSUME_NONNULL_BEGIN
2625

@@ -41,50 +40,30 @@ - (nullable instancetype)initWithProvider:(NSString *)provider {
4140
- (instancetype)initWithProviderID:(NSString *)providerID
4241
IDToken:(nullable NSString *)IDToken
4342
accessToken:(nullable NSString *)accessToken
44-
secret:(nullable NSString *)secret
4543
pendingToken:(nullable NSString *)pendingToken {
4644
self = [super initWithProvider:providerID];
4745
if (self) {
4846
_IDToken = IDToken;
4947
_accessToken = accessToken;
5048
_pendingToken = pendingToken;
51-
_secret = secret;
5249
}
5350
return self;
5451
}
5552

5653
- (instancetype)initWithProviderID:(NSString *)providerID
5754
sessionID:(NSString *)sessionID
5855
OAuthResponseURLString:(NSString *)OAuthResponseURLString {
59-
self =
60-
[self initWithProviderID:providerID IDToken:nil accessToken:nil secret:nil pendingToken:nil];
56+
self = [self initWithProviderID:providerID IDToken:nil accessToken:nil pendingToken:nil];
6157
if (self) {
6258
_OAuthResponseURLString = OAuthResponseURLString;
6359
_sessionID = sessionID;
6460
}
6561
return self;
6662
}
6763

68-
69-
- (nullable instancetype)initWithVerifyAssertionResponse:(FIRVerifyAssertionResponse *)response {
70-
if (response.oauthIDToken.length || response.oauthAccessToken.length ||
71-
response.oauthSecretToken.length) {
72-
return [self initWithProviderID:response.providerID
73-
IDToken:response.oauthIDToken
74-
accessToken:response.oauthAccessToken
75-
secret:response.oauthSecretToken
76-
pendingToken:response.pendingToken];
77-
}
78-
return nil;
79-
}
80-
8164
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
8265
request.providerIDToken = _IDToken;
8366
request.providerAccessToken = _accessToken;
84-
request.requestURI = _OAuthResponseURLString;
85-
request.sessionID = _sessionID;
86-
request.providerOAuthTokenSecret = _secret;
87-
request.pendingToken = _pendingToken;
8867
}
8968

9069
#pragma mark - NSSecureCoding
@@ -97,11 +76,9 @@ - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
9776
NSString *IDToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"IDToken"];
9877
NSString *accessToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"accessToken"];
9978
NSString *pendingToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"pendingToken"];
100-
NSString *secret = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"secret"];
10179
self = [self initWithProviderID:self.provider
10280
IDToken:IDToken
10381
accessToken:accessToken
104-
secret:secret
10582
pendingToken:pendingToken];
10683
return self;
10784
}
@@ -110,7 +87,6 @@ - (void)encodeWithCoder:(NSCoder *)aCoder {
11087
[aCoder encodeObject:self.IDToken forKey:@"IDToken"];
11188
[aCoder encodeObject:self.accessToken forKey:@"accessToken"];
11289
[aCoder encodeObject:self.pendingToken forKey:@"pendingToken"];
113-
[aCoder encodeObject:self.secret forKey:@"secret"];
11490
}
11591

11692
@end

Firebase/Auth/Source/AuthProvider/OAuth/FIROAuthCredential_Internal.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
#import "FIROAuthCredential.h"
2020

21-
@class FIRVerifyAssertionResponse;
22-
2321
NS_ASSUME_NONNULL_BEGIN
2422

2523
/** @extension FIROAuthCredential
@@ -42,18 +40,16 @@ NS_ASSUME_NONNULL_BEGIN
4240
*/
4341
@property(nonatomic, readonly, nullable) NSString *pendingToken;
4442

45-
/** @fn initWithProviderId:IDToken:accessToken:secret:pendingToken
43+
/** @fn initWithProviderId:IDToken:accessToken:pendingToken
4644
@brief Designated initializer.
4745
@param providerID The provider ID associated with the credential being created.
4846
@param IDToken The ID Token associated with the credential being created.
4947
@param accessToken The access token associated with the credential being created.
50-
@param secret The secret associated with the credential being created.
5148
@param pendingToken The pending token associated with the credential being created.
5249
*/
5350
- (instancetype)initWithProviderID:(NSString *)providerID
5451
IDToken:(nullable NSString *)IDToken
5552
accessToken:(nullable NSString *)accessToken
56-
secret:(nullable NSString *)secret
5753
pendingToken:(nullable NSString *)pendingToken NS_DESIGNATED_INITIALIZER;
5854

5955
/** @fn initWithProviderId:sessionID:OAuthResponseURLString:
@@ -66,12 +62,6 @@ NS_ASSUME_NONNULL_BEGIN
6662
sessionID:(NSString *)sessionID
6763
OAuthResponseURLString:(NSString *)OAuthResponseURLString;
6864

69-
/** @fn initWithVerifyAssertionResponse
70-
@brief Intitializer which takes an verifyAssertion response.
71-
@param response The verifyAssertion Response to create the credential instance.
72-
*/
73-
- (nullable instancetype)initWithVerifyAssertionResponse:(FIRVerifyAssertionResponse *)response;
74-
7565
@end
7666

7767
NS_ASSUME_NONNULL_END

Firebase/Auth/Source/AuthProvider/OAuth/FIROAuthProvider.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ + (FIROAuthCredential *)credentialWithProviderID:(NSString *)providerID
7171
return [[FIROAuthCredential alloc] initWithProviderID:providerID
7272
IDToken:IDToken
7373
accessToken:accessToken
74-
secret:nil
7574
pendingToken:nil];
7675
}
7776

@@ -80,7 +79,6 @@ + (FIROAuthCredential *)credentialWithProviderID:(NSString *)providerID
8079
return [[FIROAuthCredential alloc] initWithProviderID:providerID
8180
IDToken:nil
8281
accessToken:accessToken
83-
secret:nil
8482
pendingToken:nil];
8583
}
8684

Firebase/Auth/Source/Backend/FIRAuthBackend.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,13 @@ + (nullable NSError *)clientErrorWithServerErrorMessage:(NSString *)serverErrorM
10671067
NSString *email;
10681068
if ([response isKindOfClass:[FIRVerifyAssertionResponse class]]) {
10691069
FIRVerifyAssertionResponse *verifyAssertion = (FIRVerifyAssertionResponse *)response;
1070-
credential =
1071-
[[FIROAuthCredential alloc] initWithVerifyAssertionResponse:verifyAssertion];
1070+
if (verifyAssertion.oauthIDToken.length || verifyAssertion.oauthAccessToken.length) {
1071+
credential =
1072+
[[FIROAuthCredential alloc] initWithProviderID:verifyAssertion.providerID
1073+
IDToken:verifyAssertion.oauthIDToken
1074+
accessToken:verifyAssertion.oauthAccessToken
1075+
pendingToken:verifyAssertion.pendingToken];
1076+
}
10721077
email = verifyAssertion.email;
10731078
}
10741079
return [FIRAuthErrorUtils credentialAlreadyInUseErrorWithMessage:serverDetailErrorMessage

Firebase/Auth/Source/Backend/RPC/FIRVerifyAssertionResponse.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ NS_ASSUME_NONNULL_BEGIN
196196
*/
197197
@property(nonatomic, strong, readonly, nullable) NSString *oauthAccessToken;
198198

199-
/** @property oauthSecretToken
200-
@brief The secret for the OpenID OAuth extention.
201-
*/
202-
@property(nonatomic, readonly, nullable) NSString *oauthSecretToken;
203-
204199
/** @property pendingToken
205200
@brief The pending ID Token string.
206201
*/

Firebase/Auth/Source/Backend/RPC/FIRVerifyAssertionResponse.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ - (BOOL)setWithDictionary:(NSDictionary *)dictionary
7676
_oauthExpirationDate = [dictionary[@"oauthExpireIn"] isKindOfClass:[NSString class]] ?
7777
[NSDate dateWithTimeIntervalSinceNow:[dictionary[@"oauthExpireIn"] doubleValue]] : nil;
7878
_oauthAccessToken = [dictionary[@"oauthAccessToken"] copy];
79-
_oauthSecretToken = [dictionary[@"oauthTokenSecret"] copy];
8079
_pendingToken = [dictionary[@"pendingToken"] copy];
8180
return YES;
8281
}

Firebase/Auth/Source/Public/FIRAuthDataResult.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#import <Foundation/Foundation.h>
1818

1919
@class FIRAdditionalUserInfo;
20-
@class FIROAuthCredential;
2120
@class FIRUser;
2221

2322
NS_ASSUME_NONNULL_BEGIN
@@ -38,14 +37,7 @@ NS_SWIFT_NAME(AuthDataResult)
3837
/** @property user
3938
@brief The signed in user.
4039
*/
41-
@property(nonatomic, readonly, nullable) FIRUser *user;
42-
43-
/** @property credential
44-
@brief The updated OAuth credential after the the sign-in, link and reauthenticate action.
45-
@detial This property is for OAuth sign in only.
46-
*/
47-
@property(nonatomic, readonly, nullable) FIROAuthCredential *credential;
48-
40+
@property(nonatomic, readonly) FIRUser *user;
4941

5042
/** @property additionalUserInfo
5143
@brief If available contains the additional IdP specific information about signed in user.

Firebase/Auth/Source/Public/FIROAuthCredential.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ NS_SWIFT_NAME(OAuthCredential)
3636
*/
3737
@property(nonatomic, readonly, nullable) NSString *accessToken;
3838

39-
/** @property secret
40-
@brief The secret associated with this credential. This will be nil for OAuth 2.0 providers.
41-
@detail OAuthCredential already exposes a providerId getter. This will help the developer
42-
determine whether an access token/secret pair is needed.
43-
*/
44-
@property(nonatomic, readonly, nullable) NSString *secret;
45-
4639
/** @fn init
4740
@brief This class is not supposed to be instantiated directly.
4841
*/

Firebase/Auth/Source/Public/FIRTwitterAuthProvider.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ NS_ASSUME_NONNULL_BEGIN
2424
@brief A string constant identifying the Twitter identity provider.
2525
*/
2626
extern NSString *const FIRTwitterAuthProviderID NS_SWIFT_NAME(TwitterAuthProviderID);
27+
2728
/**
2829
@brief A string constant identifying the Twitter sign-in method.
2930
*/
3031
extern NSString *const _Nonnull FIRTwitterAuthSignInMethod NS_SWIFT_NAME(TwitterAuthSignInMethod);
3132

33+
3234
/** @class FIRTwitterAuthProvider
3335
@brief Utility class for constructing Twitter credentials.
3436
*/

Firebase/Auth/Source/User/FIRUser.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#import "FIRGetAccountInfoResponse.h"
4040
#import "FIRGetOOBConfirmationCodeRequest.h"
4141
#import "FIRGetOOBConfirmationCodeResponse.h"
42-
#import "FIROAuthCredential_Internal.h"
4342
#import "FIRSecureTokenService.h"
4443
#import "FIRSetAccountInfoRequest.h"
4544
#import "FIRSetAccountInfoResponse.h"
@@ -1135,12 +1134,8 @@ - (void)linkAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
11351134
}
11361135
FIRAdditionalUserInfo *additionalUserInfo =
11371136
[FIRAdditionalUserInfo userInfoWithVerifyAssertionResponse:response];
1138-
FIROAuthCredential *updatedOAuthCredential =
1139-
[[FIROAuthCredential alloc] initWithVerifyAssertionResponse:response];
11401137
FIRAuthDataResult *result =
1141-
[[FIRAuthDataResult alloc] initWithUser:self
1142-
additionalUserInfo:additionalUserInfo
1143-
credential:updatedOAuthCredential];
1138+
[[FIRAuthDataResult alloc] initWithUser:self additionalUserInfo:additionalUserInfo];
11441139
// Update the new token and refresh user info again.
11451140
self->_tokenService = [[FIRSecureTokenService alloc]
11461141
initWithRequestConfiguration:requestConfiguration

Firebase/Auth/Source/Utilities/FIRAuthErrorUtils.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,10 @@ NS_ASSUME_NONNULL_BEGIN
219219
/** @fn accountExistsWithDifferentCredentialErrorWithEmail:
220220
@brief Constructs an @c NSError with the @c FIRAuthErrorAccountExistsWithDifferentCredential
221221
code.
222-
@param email The email address that is already associated with an existing account
223-
@param updatedCredential The updated credential for the existing account
222+
@param Email The email address that is already associated with an existing account
224223
@return The NSError instance associated with the given FIRAuthError.
225224
*/
226-
+ (NSError *)accountExistsWithDifferentCredentialErrorWithEmail:(nullable NSString *)email
227-
updatedCredential:(nullable FIRAuthCredential *)updatedCredential;
225+
+ (NSError *)accountExistsWithDifferentCredentialErrorWithEmail:(nullable NSString *)Email;
228226

229227
/** @fn providerAlreadyLinkedErrorWithMessage:
230228
@brief Constructs an @c NSError with the @c FIRAuthErrorCodeProviderAlreadyLinked code.

0 commit comments

Comments
 (0)