Skip to content

Commit

Permalink
Merge pull request #1371 from AzureAD/release/4.0.0
Browse files Browse the repository at this point in the history
Merge release 4.0.0 into master
  • Loading branch information
oldalton authored Dec 22, 2018
2 parents 4b2f58c + 7e6e60a commit 7af37de
Show file tree
Hide file tree
Showing 130 changed files with 1,239 additions and 6,179 deletions.
6 changes: 3 additions & 3 deletions ADAL.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "ADAL"
s.module_name = "ADAL"
s.version = "2.7.7"
s.version = "4.0.0"
s.summary = "The ADAL SDK for iOS gives you the ability to add Azure Identity authentication to your application"

s.description = <<-DESC
Expand All @@ -15,8 +15,8 @@ Pod::Spec.new do |s|
s.authors = { "Microsoft" => "[email protected]" }
s.social_media_url = "https://twitter.com/azuread"
s.platform = :ios, :osx
s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.10"
s.ios.deployment_target = "10.0"
s.osx.deployment_target = "10.11"
s.source = {
:git => "https://github.com/AzureAD/azure-activedirectory-library-for-objc.git",
:tag => s.version.to_s,
Expand Down
5 changes: 1 addition & 4 deletions ADAL.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
<dict/>
</plist>
359 changes: 83 additions & 276 deletions ADAL/ADAL.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#pragma once

typedef void (^ADAutoParamBlock)(NSDictionary<NSString *, NSString *> * parameters);

#import <WebKit/WebKit.h>

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
@compatibility_alias ADAutoViewController UIViewController;
#else
#import <Cocoa/Cocoa.h>
@compatibility_alias ADAutoViewController NSViewController;
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,21 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#endif
#import "ADALAutomation.h"

@class ADAutoRequestViewController;
@class ADAutoWebViewController;
@class ADAutoPassedInWebViewController;
@class ADAuthenticationContext;
@protocol ADTokenCacheDataSource;

#if TARGET_OS_IPHONE
@interface ADAutoViewController : UIViewController
#else
@interface ADAutoViewController : NSViewController
#endif
@interface ADAutoBaseViewController: ADAutoViewController

@property (nonatomic) ADAutoRequestViewController *requestViewController;
@property (nonatomic) ADAutoWebViewController *webViewController;
@property (nonatomic) WKWebView *webView;

- (void)showActionSelectionView;
- (void)showRequestDataViewWithCompletionHandler:(ADAutoParamBlock)completionHandler;
- (void)showResultViewWithResult:(NSString *)resultJson logs:(NSString *)resultLogs;
- (void)showPassedInWebViewControllerWithContext:(ADAuthenticationContext *)context;
- (void)dismissPassedInWebViewController;
- (id<ADTokenCacheDataSource>)cacheDatasource;
- (void)clearCache;
- (void)clearKeychain;
Expand Down
4 changes: 2 additions & 2 deletions ADAL/automation/ADAutoMainViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "ADAutoViewController.h"
#import "ADAutoBaseViewController.h"

@interface ADAutoMainViewController : ADAutoViewController
@interface ADAutoMainViewController : ADAutoBaseViewController

@end
24 changes: 19 additions & 5 deletions ADAL/automation/ADAutoMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ - (ADAuthenticationContext *)contextFromParameters:(NSDictionary *)parameters
{
[self showPassedInWebViewControllerWithContext:context];
}
else
{
context.webView = nil;
}

if (parameters[@"use_broker"])
{
Expand Down Expand Up @@ -188,7 +192,6 @@ - (IBAction)acquireToken:(__unused id)sender
completionBlock:^(ADAuthenticationResult *result)
{
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf dismissPassedInWebViewController];
[weakSelf displayAuthenticationResult:result logs:weakSelf.resultLogs];
});
}];
Expand Down Expand Up @@ -220,13 +223,14 @@ - (IBAction)acquireTokenSilent:(__unused id)sender
clientId:parameters[@"client_id"]
redirectUri:[NSURL URLWithString:parameters[@"redirect_uri"]]
userId:parameters[@"user_identifier"]
claims:parameters[@"claims"]
completionBlock:^(ADAuthenticationResult *result) {

dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf displayAuthenticationResult:result logs:weakSelf.resultLogs];
});
}];

}];
};

[self showRequestDataViewWithCompletionHandler:completionBlock];
Expand Down Expand Up @@ -267,6 +271,15 @@ - (IBAction)clearCookies:(id)sender
count++;
}

// Clear WKWebView cookies

NSSet *allTypes = [WKWebsiteDataStore allWebsiteDataTypes];
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:allTypes
modifiedSince:[NSDate dateWithTimeIntervalSince1970:0]
completionHandler:^{
NSLog(@"Completed!");
}];

[self showResultViewWithResult:[NSString stringWithFormat:@"{\"cleared_items_count\":\"%lu\"}", (unsigned long)count] logs:_resultLogs];
}

Expand Down Expand Up @@ -295,8 +308,8 @@ - (IBAction)invalidateRefreshToken:(__unused id)sender
id<ADTokenCacheDataSource> cache = [self cacheDatasource];

NSMutableArray<ADTokenCacheItem *> *allItems = [NSMutableArray new];

MSIDAADAuthority *authority = [[MSIDAADAuthority alloc] initWithURL:[NSURL URLWithString:parameters[@"authority"]] context:nil error:nil];
__auto_type authority = [[MSIDAADAuthority alloc] initWithURL:[NSURL URLWithString:parameters[@"authority"]] context:nil error:nil];

NSArray *aliases = nil;

Expand Down Expand Up @@ -497,7 +510,7 @@ - (IBAction)acquireTokenByRefreshToken:(id)sender
clientId:parameters[@"client_id"]
redirectUri:[NSURL URLWithString:parameters[@"redirect_uri"]]
completionBlock:^(ADAuthenticationResult *result) {

dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf displayAuthenticationResult:result logs:weakSelf.resultLogs];
});
Expand Down Expand Up @@ -620,6 +633,7 @@ - (NSString *)createJsonFromResult:(ADAuthenticationResult *)result
if(result.error){
[resultDict setValue:result.error.errorDetails forKey:@"error"];
[resultDict setValue:result.error.description forKey:@"error_description"];
[resultDict setValue:[ADAuthenticationError stringForADErrorCode:result.error.code] forKey:@"error_code"];
}
else {
NSString * isExtLtString = (result.extendedLifeTimeToken) ? @"true" : @"false";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

@interface UIApplication ( internal )
#import "ADALAutomation.h"

+ (UIViewController *)adCurrentViewController;
@interface ADAutoPassedInWebViewController : ADAutoViewController

@property (nonatomic, weak) WKWebView *passedInWebview;

@end
4 changes: 2 additions & 2 deletions ADAL/automation/ADAutoRequestViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "ADAutoViewController.h"
#import "ADALAutomation.h"

@interface ADAutoRequestViewController : ADAutoViewController

#if TARGET_OS_IPHONE
@property (strong, nonatomic) IBOutlet UITextView *requestInfo;
@property (weak, nonatomic) IBOutlet UITextView *requestInfo;

#else
@property (strong, nonatomic) IBOutlet NSTextView *requestInfo;
#endif
Expand Down
2 changes: 1 addition & 1 deletion ADAL/automation/ADAutoResultViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "ADAutoViewController.h"
#import "ADALAutomation.h"

@interface ADAutoResultViewController : ADAutoViewController

Expand Down
34 changes: 0 additions & 34 deletions ADAL/automation/ADAutoWebViewController.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,57 +21,59 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "ADAutoViewController.h"
#import "ADAutoBaseViewController.h"
#import "ADAutoRequestViewController.h"
#import "ADAutoResultViewController.h"
#import "ADAutoWebViewController.h"
#import "ADAutoPassedInWebViewController.h"
#import "ADAL.h"
#import "ADTokenCacheDataSource.h"
#import "ADKeychainTokenCache+Internal.h"
#import "MSIDKeychainTokenCache.h"
#import <WebKit/WebKit.h>

@interface ADAutoViewController ()
@interface ADAutoBaseViewController ()

@end

@implementation ADAutoViewController
@implementation ADAutoBaseViewController

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
(void)sender;

if ([segue.identifier isEqualToString:@"showResult"])
{
ADAutoResultViewController *resultVC = segue.destinationViewController;
resultVC.resultInfoString = sender[@"resultInfo"];
resultVC.resultLogsString = sender[@"resultLogs"];
}
}

- (void)showActionSelectionView
{
if (self.presentedViewController)

if ([segue.identifier isEqualToString:@"showRequest"])
{
[self.presentedViewController dismissViewControllerAnimated:NO completion:nil];
ADAutoRequestViewController *requestVC = segue.destinationViewController;
requestVC.requestInfo.text = nil;
requestVC.completionBlock = sender[@"completionHandler"];
}

if ([segue.identifier isEqualToString:@"showPassedInWebview"])
{
ADAutoPassedInWebViewController *requestVC = segue.destinationViewController;
requestVC.passedInWebview = sender[@"webview"];
}
}


- (void)showRequestDataViewWithCompletionHandler:(ADAutoParamBlock)completionHandler
{
self.requestViewController = [ADAutoRequestViewController new];
self.requestViewController.completionBlock = completionHandler;
self.requestViewController.requestInfo.text = nil;
[self presentViewController:self.requestViewController animated:NO completion:nil];
[self performSegueWithIdentifier:@"showRequest"
sender:@{@"completionHandler":completionHandler}];
}


- (void)showResultViewWithResult:(NSString *)resultJson logs:(NSString *)resultLogs
{
if (self.presentedViewController)
{
[self.presentedViewController dismissViewControllerAnimated:NO completion:^{

[self presentResults:resultJson logs:resultLogs];

}];
}
else
Expand All @@ -80,26 +82,29 @@ - (void)showResultViewWithResult:(NSString *)resultJson logs:(NSString *)resultL
}
}

- (void)showPassedInWebViewControllerWithContext:(ADAuthenticationContext *)context
- (void)presentResults:(NSString *)resultJson logs:(NSString *)resultLogs
{
self.webViewController = [ADAutoWebViewController new];
__unused id view = self.webViewController.view;
[context setWebView:self.webViewController.webView];
[self.requestViewController presentViewController:self.webViewController
animated:NO
completion:nil];
[self performSegueWithIdentifier:@"showResult" sender:@{@"resultInfo":resultJson ? resultJson : @"",
@"resultLogs":resultLogs ? resultLogs : @""}];
}

- (void)dismissPassedInWebViewController
- (void)showPassedInWebViewControllerWithContext:(ADAuthenticationContext *)context
{
[self.webViewController dismissViewControllerAnimated:NO completion:nil];
self.webViewController = nil;
context.webView = self.webView;

[self.webView loadHTMLString:@"<html><head></head><body>Loading...</body></html>" baseURL:nil];
[self performSegueWithIdentifier:@"showPassedInWebview" sender:@{@"context" : context,
@"webview" : self.webView
}];
}

- (void)presentResults:(NSString *)resultJson logs:(NSString *)resultLogs
- (void)viewDidLoad
{
[self performSegueWithIdentifier:@"showResult" sender:@{@"resultInfo":resultJson ? resultJson : @"",
@"resultLogs":resultLogs ? resultLogs : @""}];
[super viewDidLoad];

self.webView = [[WKWebView alloc] init];
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

}

- (id<ADTokenCacheDataSource>)cacheDatasource
Expand Down
Loading

0 comments on commit 7af37de

Please sign in to comment.