Skip to content
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

Webview integration #1262

Merged
merged 34 commits into from
Sep 7, 2018
Merged

Webview integration #1262

merged 34 commits into from
Sep 7, 2018

Conversation

unpluggedk
Copy link
Contributor

No description provided.

@@ -32,8 +33,8 @@ @implementation ADAutoWebViewController
- (void)viewDidLoad
{
[super viewDidLoad];

self.webView.accessibilityIdentifier = @"ADAL_SIGN_IN_WEBVIEW";
self.webView = [[WKWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fixed in your other PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it has

@property (retain, nonatomic) NSString *redirectUri;
@property (retain, nonatomic) NSString *scopesString;
@property (retain, nonatomic) ADUserIdentifier *identifier;
@property (retain, nonatomic) NSString *claims;
Copy link
Member

@oldalton oldalton Aug 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should we add claims and extra query parameters also into the initializer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use the initializer in the code, I will actually remove the initializer.

@@ -328,7 +328,7 @@ + (NSDictionary *)decryptBrokerResponse:(NSDictionary *)response correlationId:(
}

//now compute the hash on the unencrypted data
NSString *actualHash = [ADPkeyAuthHelper computeThumbprint:decrypted isSha2:YES];
NSString *actualHash = [MSIDPkeyAuthHelper computeThumbprint:decrypted isSha2:YES];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's funny that we have Sha2 computation only inside PkeyAuthHelper :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:neckbeard:

@@ -301,7 +309,7 @@ - (void)requestToken:(ADAuthenticationCallback)completionBlock
return;
}

if (_silent && !_allowSilent)
if (_silent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume allow Silent was removed because it's only used in broker?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is correct


if (error)
{
ADAuthenticationResult *result = (AD_ERROR_UI_USER_CANCEL == error.code) ? [ADAuthenticationResult resultFromCancellation:_requestParams.correlationId]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we automatically fallback to interactive flow if it's a silent request (AD_PROMPT_AUTO scenario)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already in interactive flow. I may be misunderstanding your question, so let's sync offline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As settled in the offline discussion, this is strictly broker flow, thus we are fine with not having this logic.

{
MSID_LOG_VERBOSE(_requestParams, @"-webAuthDidFinishLoad host: %@", [ADAuthorityUtils isKnownHost:url] ? url.host : @"unknown host");
MSID_LOG_VERBOSE_PII(_requestParams, @"-webAuthDidFinishLoad host: %@", url.host);
NSString *authorityWithOAuthSuffix = [NSString stringWithFormat:@"%@%@", context.authority, MSID_OAUTH2_AUTHORIZE_SUFFIX];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shouldn't we have a common core or ADAL utility to compose this url?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is being addressed in AzureAD/microsoft-authentication-library-common-for-objc#130 ,
I will at least add some comment on this to update when the above PR is merged.

}

// The user cancelled authentication
- (void)webAuthDidCancel
+ (NSDictionary *)dictFromQueryString:(NSString *)query
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if this is still not available in common core, let's move this utility there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point, common core's utility needs revision I think.
Query params can have key-only value and our utility does not account for this.


+ (ADAuthenticationResult*)responseFromInterruptedBrokerSession
- (void)cancelCurrentWebAuthSession
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this duplicate with line 121?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and removed one of them.

@@ -289,7 +289,7 @@ - (IBAction)acquireTokenInteractive:(id)sender

if ([_acquireSettingsView isHidden])
{
[_webView.mainFrame loadHTMLString:@"<html><head></head><body>done!</body></html>" baseURL:nil];
[_webView loadHTMLString:@"<html><head></head><body>Done</body></html>" baseURL:nil];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very important change :)

@@ -29,7 +29,7 @@
@interface ADTestAppAcquireTokenWindowController : NSWindowController
{
IBOutlet NSView* _authView;
IBOutlet WebView* _webView;
IBOutlet WKWebView* _webView;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WKWebView is not supported on older OS-s as IBOutlet (in storyboard). I think you might still be using WebView in storyboard or how can it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@unpluggedk unpluggedk dismissed oldalton’s stale review August 30, 2018 22:54

Feedback addressed or answered.

Copy link
Member

@oldalton oldalton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a we minor telemetry issues and url opening issues. Please check them out before merging.

ADAuthenticationResult *result = [ADAuthenticationResult resultFromError:error correlationId:_requestParams.correlationId];
[result setCloudAuthority:_cloudAuthority];
completionHandler(result);
return YES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think telemetry event gets stopped in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We stopped it in line 560 before coming in here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I missed that line :)

[ADBrokerHelper promptBrokerInstall:[NSURL URLWithString:authResponse.appInstallLink]
brokerRequest:brokerRequestURL
completionHandler:completionHandler];
return YES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think telemetry event gets stopped in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We stopped it in line 560 before coming in here.

[MSIDAppExtensionUtil sharedApplicationOpenURL:browserURL];
});

[MSIDAppExtensionUtil sharedApplicationOpenURL:browserURL];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't call sharedApplicationOpenURL twice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, fixed! Removed the first one as this method will check the main queue later anyways.


MSIDWebOAuth2Response *oauthResponse = (MSIDWebOAuth2Response *)response;

if (oauthResponse.authorizationCode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we check if it's empty too? (msidIsNilOrEmpty)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better handled at common,
AzureAD/microsoft-authentication-library-common-for-objc#223

#if TARGET_OS_IPHONE
[_authenticationViewController setParentController:parent];
[_authenticationViewController setFullScreen:fullScreen];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we remove the fullScreen functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced it with presentationStyle. Also marked it deprecated.


IBOutlet NSView *_contentWebView;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we call it contentView or webviewContentView?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has 2 "views", and still sound ugly :p thus, I refuse to change this

@unpluggedk unpluggedk merged commit 04319bd into dev Sep 7, 2018
@unpluggedk unpluggedk deleted the jak/webview-integration branch September 7, 2018 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants