following ADAL webview with websso site webview (with IDP’s cookies)

Based on the IOS sample for ADAL, we amended the initial table controller – setup to show table of todos. We simply overlaid a webview and bound the view’s control to a variable in the controller class.

Then we amended the callback chain – which normally refreshes the listing view having obtained a list from the authenticated API call. Rather than refresh, we populate a page into our web view – a page served by an SP also served by the IDP just used to create an ADAL managed token (for webAPI usage). So the IDP will assert, we injected the IDP-minted cookies – created during the ADAL interaction moments earlier:

Screen Shot 2014-06-12 at 5.15.43 PM

For easy selection, the code is


 	else         {             self.taskItems = (NSMutableArray*)tasks;                          // Refresh main thread since we are async             dispatch_async(dispatch_get_main_queue(), ^{       //          [self.tableView reloadData];                 NSString *fullURL = @””;                 NSURL *url = [NSURL URLWithString:fullURL];                 NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];                                  NSArray *cookiesForDomain = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:@"..."];                                  if (cookieStringToSet.length) {                     [requestObj setValue:cookieStringToSet forHTTPHeaderField:@"Cookie"];                 }                 [_webView loadRequest:requestObj];              });         }  

About home_pw

Computer Programmer who often does network administration with focus on security servers. Sometimes plays at slot machine programming.
This entry was posted in AAD. Bookmark the permalink.