-
Notifications
You must be signed in to change notification settings - Fork 213
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
Manual nonce generation option #244
Changes from all commits
a593b4f
d0cf7cd
6673687
b0543cd
76acf9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,6 +269,7 @@ - (void)signInWithPresentingViewController:(UIViewController *)presentingViewCon | |
- (void)addScopes:(NSArray<NSString *> *)scopes | ||
presentingViewController:(UIViewController *)presentingViewController | ||
completion:(nullable GIDSignInCompletion)completion { | ||
|
||
GIDConfiguration *configuration = self.currentUser.configuration; | ||
GIDSignInInternalOptions *options = | ||
[GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration | ||
|
@@ -570,21 +571,31 @@ - (void)authenticateInteractivelyWithOptions:(GIDSignInInternalOptions *)options | |
|
||
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
[additionalParameters addEntriesFromDictionary: | ||
[GIDEMMSupport parametersWithParameters:options.extraParams | ||
emmSupport:emmSupport | ||
isPasscodeInfoRequired:NO]]; | ||
[GIDEMMSupport parametersWithParameters:options.extraParams | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indentation. |
||
emmSupport:emmSupport | ||
isPasscodeInfoRequired:NO]]; | ||
#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST | ||
[additionalParameters addEntriesFromDictionary:options.extraParams]; | ||
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST | ||
additionalParameters[kSDKVersionLoggingParameter] = GIDVersion(); | ||
additionalParameters[kEnvironmentLoggingParameter] = GIDEnvironment(); | ||
|
||
NSString *codeVerifier = [OIDAuthorizationRequest generateCodeVerifier]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part is a little tricky for me because it looks like GSI is taking on some of the implementation details within AppAuth-iOS. IIUC, we have to create Ideally, we would have an initializer on What do you think? |
||
NSString *codeChallenge = [OIDAuthorizationRequest codeChallengeS256ForVerifier:codeVerifier]; | ||
NSString *nonce = options.configuration.nonce ? options.configuration.nonce : [OIDAuthorizationRequest generateState]; | ||
|
||
OIDAuthorizationRequest *request = | ||
[[OIDAuthorizationRequest alloc] initWithConfiguration:_appAuthConfiguration | ||
clientId:options.configuration.clientID | ||
scopes:options.scopes | ||
clientSecret:nil | ||
scope:[OIDScopeUtilities scopesWithArray:options.scopes] | ||
redirectURL:redirectURL | ||
responseType:OIDResponseTypeCode | ||
state:[OIDAuthorizationRequest generateState] | ||
nonce:nonce | ||
codeVerifier:codeVerifier | ||
codeChallenge:codeChallenge | ||
codeChallengeMethod:OIDOAuthorizationRequestCodeChallengeMethodS256 | ||
additionalParameters:additionalParameters]; | ||
|
||
_currentAuthorizationFlow = [OIDAuthorizationService | ||
|
@@ -1031,13 +1042,14 @@ + (nullable GIDConfiguration *)configurationFromBundle:(NSBundle *)bundle { | |
forKey:kConfigServerClientIDKey]; | ||
NSString *hostedDomain = [GIDSignIn configValueFromBundle:bundle forKey:kConfigHostedDomainKey]; | ||
NSString *openIDRealm = [GIDSignIn configValueFromBundle:bundle forKey:kConfigOpenIDRealmKey]; | ||
|
||
// If we have at least a client ID, try to construct a configuration. | ||
if (clientID) { | ||
configuration = [[GIDConfiguration alloc] initWithClientID:clientID | ||
serverClientID:serverClientID | ||
hostedDomain:hostedDomain | ||
openIDRealm:openIDRealm]; | ||
openIDRealm:openIDRealm | ||
nonce:nil]; | ||
} | ||
|
||
return configuration; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -639,10 +639,11 @@ - (void)testAddScopes { | |
} | ||
|
||
- (void)testOpenIDRealm { | ||
_signIn.configuration = [[GIDConfiguration alloc] initWithClientID:kClientId | ||
serverClientID:nil | ||
hostedDomain:nil | ||
openIDRealm:kOpenIDRealm]; | ||
_signIn._configuration = [[GIDConfiguration alloc] initWithClientID:kClientId | ||
serverClientID:nil | ||
hostedDomain:nil | ||
openIDRealm:kOpenIDRealm | ||
nonce:nil]; | ||
|
||
[self OAuthLoginWithAddScopesFlow:NO | ||
authError:nil | ||
|
@@ -674,10 +675,12 @@ - (void)testOAuthLogin_LoginHint { | |
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that It'd be great to have a unit test that asserts: |
||
- (void)testOAuthLogin_HostedDomain { | ||
_signIn.configuration = [[GIDConfiguration alloc] initWithClientID:kClientId | ||
serverClientID:nil | ||
hostedDomain:kHostedDomain | ||
openIDRealm:nil]; | ||
|
||
_signIn._configuration = [[GIDConfiguration alloc] initWithClientID:kClientId | ||
serverClientID:nil | ||
hostedDomain:kHostedDomain | ||
openIDRealm:nil | ||
nonce:nil]; | ||
|
||
[self OAuthLoginWithAddScopesFlow:NO | ||
authError:nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space.