Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Add option for user to select browser type to use for browser based authentication #265

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7430418
Merge pull request #122 from CAAPIM/Stable
BobbyWeber Dec 14, 2017
553eb10
Merge branch 'Stable'
BobbyWeber Dec 21, 2017
00dbbef
Merge branch 'Stable'
BobbyWeber Mar 2, 2018
c14b271
Merge branch 'Stable'
BobbyWeber Jun 13, 2018
75d6c76
Merge branch 'Stable'
BobbyWeber Jul 11, 2018
ef25850
Merge branch 'Stable'
BobbyWeber Aug 27, 2018
90fb3f4
Merge branch 'Stable'
BobbyWeber Dec 7, 2018
65706bf
Merge branch 'Stable'
BobbyWeber Feb 19, 2019
7fc8754
Merge branch 'Stable'
BobbyWeber Feb 19, 2019
9ab0730
iOS13 Changes for ASN.1 decoding null pointer bit string issue
ysd24 Sep 3, 2019
e43509b
Removing Mac Catalyst Support for Final build
BobbyWeber Sep 13, 2019
f93934b
Removing Mac Catalyst Support for Final Build
BobbyWeber Sep 13, 2019
31c4231
Fixing test targets for iOS 13
BobbyWeber Sep 17, 2019
8682e50
Updated changelog for 1.9.20
ysd24 Sep 18, 2019
bc1d6b2
Merge pull request #224 from CAAPIM/iOS-13-Master
manutripathi82 Sep 18, 2019
374c7b3
Merge branch 'develop' into merge-develop
Oct 3, 2019
cecb20d
Merge pull request #232 from CAAPIM/merge-develop
manutripathi82 Oct 3, 2019
bdc0bad
Merge pull request #250 from CAAPIM/develop
manutripathi82 Mar 12, 2020
1e6d309
Added the option for a user to configure what browser they want to us…
Dec 8, 2020
6423696
Fixed indentation
Dec 8, 2020
9428327
Remove unneeded edits to the project file
Dec 8, 2020
ef20369
Remove workspace checks
Dec 8, 2020
a2374bc
Remove more unneeded edits
Dec 8, 2020
33158cf
Add some more whitespaces to adhere to coding guidelines
Dec 8, 2020
6a2da19
Added pragma marks, and utility log statements
Dec 8, 2020
7ee1716
Change __block to __weak to prevent possible retain cycles
Dec 8, 2020
b492e32
Missed 1 weakSelf
Dec 8, 2020
7c48c43
Added option to provide the callack url scheme when choosing to use w…
Dec 22, 2020
4e6029d
Removed the need to provide a url scheme when using the Web session b…
Feb 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion MASFoundation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
A898EF682182D35700CF291B /* MASJWKSet.m in Sources */ = {isa = PBXBuildFile; fileRef = A898EF662182D35700CF291B /* MASJWKSet.m */; };
A898EF6B2182D3DF00CF291B /* NSURLSession+MASPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A898EF692182D3DF00CF291B /* NSURLSession+MASPrivate.h */; };
A898EF6C2182D3DF00CF291B /* NSURLSession+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = A898EF6A2182D3DF00CF291B /* NSURLSession+MASPrivate.m */; };
C81CC3CC1FC2EA190058718E /* MASBrowserBasedAuthentication.h in Headers */ = {isa = PBXBuildFile; fileRef = C81CC3CA1FC2EA190058718E /* MASBrowserBasedAuthentication.h */; };
C81CC3CC1FC2EA190058718E /* MASBrowserBasedAuthentication.h in Headers */ = {isa = PBXBuildFile; fileRef = C81CC3CA1FC2EA190058718E /* MASBrowserBasedAuthentication.h */; settings = {ATTRIBUTES = (Public, ); }; };
C81CC3D01FC2EFBB0058718E /* UIAlertController+MAS.h in Headers */ = {isa = PBXBuildFile; fileRef = C81CC3CE1FC2EFBB0058718E /* UIAlertController+MAS.h */; };
C81CC3D11FC2EFBB0058718E /* UIAlertController+MAS.m in Sources */ = {isa = PBXBuildFile; fileRef = C81CC3CF1FC2EFBB0058718E /* UIAlertController+MAS.m */; };
C858D6B52398FC5400963763 /* MASDataTask+MASPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = C858D6B32398FC5400963763 /* MASDataTask+MASPrivate.h */; };
Expand Down Expand Up @@ -326,6 +326,8 @@
CBD25B151E7A0A9200DFB47F /* MF_Base64Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = CBD25B131E7A0A9200DFB47F /* MF_Base64Additions.m */; };
CBFA70F41F1ED5D6006D025D /* MASSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = CBFA70F21F1ED5D6006D025D /* MASSecurityPolicy.h */; };
CBFA70F51F1ED5D6006D025D /* MASSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = CBFA70F31F1ED5D6006D025D /* MASSecurityPolicy.m */; };
E0A461A72590972200C21439 /* MASBrowserBasedAuthenticationConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = E0A461A62590972200C21439 /* MASBrowserBasedAuthenticationConfiguration.m */; };
E0A461AA2590985900C21439 /* MASBrowserBasedAuthenticationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = E0A461A12590955B00C21439 /* MASBrowserBasedAuthenticationConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
E0BA784D257E7FEF0003A9B8 /* MASSafariBrowserBasedAuthentication.m in Sources */ = {isa = PBXBuildFile; fileRef = E0BA784B257E7FEF0003A9B8 /* MASSafariBrowserBasedAuthentication.m */; };
E0BA7861257EB8C00003A9B8 /* MASWebSessionBrowserBasedAuthentication.m in Sources */ = {isa = PBXBuildFile; fileRef = E0BA785F257EB8C00003A9B8 /* MASWebSessionBrowserBasedAuthentication.m */; };
E0BA7867257F62570003A9B8 /* MASSafariBrowserBasedAuthentication.h in Headers */ = {isa = PBXBuildFile; fileRef = E0BA784A257E7FEF0003A9B8 /* MASSafariBrowserBasedAuthentication.h */; };
Expand Down Expand Up @@ -694,6 +696,8 @@
CBD25B131E7A0A9200DFB47F /* MF_Base64Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MF_Base64Additions.m; sourceTree = "<group>"; };
CBFA70F21F1ED5D6006D025D /* MASSecurityPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASSecurityPolicy.h; sourceTree = "<group>"; };
CBFA70F31F1ED5D6006D025D /* MASSecurityPolicy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASSecurityPolicy.m; sourceTree = "<group>"; };
E0A461A12590955B00C21439 /* MASBrowserBasedAuthenticationConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASBrowserBasedAuthenticationConfiguration.h; sourceTree = "<group>"; };
E0A461A62590972200C21439 /* MASBrowserBasedAuthenticationConfiguration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MASBrowserBasedAuthenticationConfiguration.m; sourceTree = "<group>"; };
E0BA7849257E7FA60003A9B8 /* MASTypedBrowserBasedAuthenticationInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASTypedBrowserBasedAuthenticationInterface.h; sourceTree = "<group>"; };
E0BA784A257E7FEF0003A9B8 /* MASSafariBrowserBasedAuthentication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASSafariBrowserBasedAuthentication.h; sourceTree = "<group>"; };
E0BA784B257E7FEF0003A9B8 /* MASSafariBrowserBasedAuthentication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MASSafariBrowserBasedAuthentication.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1015,6 +1019,8 @@
CB1FD14A1FB23701000AFA25 /* MASSharedStorage.m */,
C81CC3CA1FC2EA190058718E /* MASBrowserBasedAuthentication.h */,
C81CC3CB1FC2EA190058718E /* MASBrowserBasedAuthentication.m */,
E0A461A12590955B00C21439 /* MASBrowserBasedAuthenticationConfiguration.h */,
E0A461A62590972200C21439 /* MASBrowserBasedAuthenticationConfiguration.m */,
);
path = models;
sourceTree = "<group>";
Expand Down Expand Up @@ -1588,6 +1594,7 @@
CBAFD2501F2BD48B0034DF02 /* MASSecurityConfiguration+MASPrivate.h in Headers */,
CB23579A1F100EC400D4C420 /* MASSessionDataTaskOperation.h in Headers */,
A4831AB31BD1A551007B4AE6 /* MASObject.h in Headers */,
E0A461AA2590985900C21439 /* MASBrowserBasedAuthenticationConfiguration.h in Headers */,
E3662A3F23DEE557007A76A1 /* MASISecurityPolicy.h in Headers */,
CBD25AF71E78C47C00DFB47F /* JWTCryptoSecurity.h in Headers */,
CB58986B1F183E0A005C1E82 /* MASAuthValidationOperation.h in Headers */,
Expand Down Expand Up @@ -1947,6 +1954,7 @@
E3662A3B23DEE52C007A76A1 /* MASIURLResponseSerialization.m in Sources */,
69B7DF6B1F9675600056DD3A /* MASRequestBuilder.m in Sources */,
CBBA9A8120742BA800BB307F /* MASNetworkReachability.m in Sources */,
E0A461A72590972200C21439 /* MASBrowserBasedAuthenticationConfiguration.m in Sources */,
A4150EFE1BF16EE200037E27 /* MASSecurityService.m in Sources */,
A46F49C21C2F5FC500A4C370 /* MASIKeyChainStore.m in Sources */,
CB1907F91C17950700A5EF16 /* MASAccessService.m in Sources */,
Expand Down
9 changes: 5 additions & 4 deletions MASFoundation/Classes/MAS.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "MASRequest.h"
#import "MASMultiFactorAuthenticator.h"
#import "MASMultiPartFormData.h"
#import "MASBrowserBasedAuthenticationConfiguration.h"

/**
* The top level MAS object represents the Mobile App Services SDK in it's entirety. It
Expand Down Expand Up @@ -196,12 +197,12 @@


/**
* Sets preferred type of browser used for Browser Based Authentication (templatized login).
* By default this is `MASBrowserBasedAuthenticationTypeSafari`.
* Sets a configuration to use for Browser Based Authentication (templatized login).
* By default this is `MASSafariBrowserBasedAuthenticationConfiguration`.

@param browserBasedAuthenticationType MASBrowserBasedAuthenticationType value indicating which type of browser should be used for Browser Based Authentication.
@param configuration MASBrowserBasedAuthenticationConfigurationInterface conforming object to configure the browser based authentication..
*/
+ (void)preferredBrowserBasedAuthenticationType:(MASBrowserBasedAuthenticationType)browserBasedAuthenticationType;
+ (void)preferredBrowserBasedAuthenticationConfiguration:(id<MASBrowserBasedAuthenticationConfigurationInterface> _Nonnull)configuration;


/**
Expand Down
4 changes: 2 additions & 2 deletions MASFoundation/Classes/MAS.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ + (void)enableBrowserBasedAuthentication:(BOOL)enable
}


+ (void)preferredBrowserBasedAuthenticationType:(MASBrowserBasedAuthenticationType)browserBasedAuthenticationType
+ (void)preferredBrowserBasedAuthenticationConfiguration:(id<MASBrowserBasedAuthenticationConfigurationInterface> _Nonnull)configuration
{
[MASModelService setBrowserBasedAuthenticationType:browserBasedAuthenticationType];
[MASModelService setBrowserBasedAuthenticationConfiguration:configuration];
}


Expand Down
16 changes: 0 additions & 16 deletions MASFoundation/Classes/MASConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,6 @@ typedef NS_ENUM(NSInteger, MASState) {
};


/**
* The enumerated MASBrowserBasedAuthenticationTypes that can be used to initiate a browser based login
*/
typedef NS_CLOSED_ENUM(NSUInteger, MASBrowserBasedAuthenticationType) {

/**
* Type which tells the SDK an SFSafariViewController should be used when the user invokes browser based authentication.
*/
MASBrowserBasedAuthenticationTypeSafari,
/**
* Type which tells the SDK an ASWebAuthenticationSession should be used when the user invokes browser based authentication.
*/
MASBrowserBasedAuthenticationTypeWebSession API_AVAILABLE(ios(12.0), macCatalyst(13.0), macos(10.15), watchos(6.2)) API_UNAVAILABLE(tvos)
};


/**
* Enumerated MASFileDirectoryType that indicates which directory to store MASFile into.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "MASConstants.h"

@protocol MASTypedBrowserBasedAuthenticationInterface;
@protocol MASBrowserBasedAuthenticationConfigurationInterface;

/**
* Utility factory class to build the correct browser type to use
Expand All @@ -21,9 +22,9 @@
/**
* Build a new browser used for Browser Based Authentication
*
* @param browserBasedAuthenticationType A MASBrowserBasedAuthenticationType object telling the factory what to build information.
* @param configuration MASBrowserBasedAuthenticationConfigurationInterface conforming object telling the factory what and how to build its product.
* @return id<MASTypedBrowserBasedAuthenticationInterface> object which can be used to start Browser Based Authentication.
*/
+ (id<MASTypedBrowserBasedAuthenticationInterface>)buildBrowserForType:(MASBrowserBasedAuthenticationType)browserBasedAuthenticationType;
+ (id<MASTypedBrowserBasedAuthenticationInterface>)buildBrowserWithConfiguration:(id<MASBrowserBasedAuthenticationConfigurationInterface>)configuration;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,29 @@
//

#import "MASTypedBrowserBasedAuthenticationFactory.h"
#import "MASBrowserBasedAuthenticationConfiguration.h"
#import "MASSafariBrowserBasedAuthentication.h"
#import "MASWebSessionBrowserBasedAuthentication.h"

@implementation MASTypedBrowserBasedAuthenticationFactory

+ (id<MASTypedBrowserBasedAuthenticationInterface>)buildBrowserForType:(MASBrowserBasedAuthenticationType)browserBasedAuthenticationType {
if (@available(iOS 12.0, macOS 10.15, *)) {
switch (browserBasedAuthenticationType) {
case MASBrowserBasedAuthenticationTypeSafari:
return [[MASSafariBrowserBasedAuthentication alloc] init];
case MASBrowserBasedAuthenticationTypeWebSession:
return [[MASWebSessionBrowserBasedAuthentication alloc] init];
}
} else {
+ (id<MASTypedBrowserBasedAuthenticationInterface>)buildBrowserWithConfiguration:(id<MASBrowserBasedAuthenticationConfigurationInterface>)configuration {

if ([configuration isKindOfClass: [MASSafariBrowserBasedAuthenticationConfiguration class]])
{
return [[MASSafariBrowserBasedAuthentication alloc] init];
}
if (@available(iOS 12.0, macOS 10.15, *))
{
if ([configuration isKindOfClass: [MASWebSessionBrowserBasedAuthenticationConfiguration class]])
{
MASWebSessionBrowserBasedAuthenticationConfiguration *castedConfiguration = configuration;

return [[MASWebSessionBrowserBasedAuthentication alloc] initWithCallbackURLScheme:castedConfiguration.callbackURLScheme];
}
}

@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Cannot produce result with the provided configuration." userInfo:nil];
return nil;
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

#import <Foundation/Foundation.h>



NS_ASSUME_NONNULL_BEGIN



@protocol MASTypedBrowserBasedAuthenticationInterface;

/**
Expand All @@ -18,4 +24,23 @@
API_AVAILABLE(ios(12.0), macCatalyst(13.0), macos(10.15), watchos(6.2))
@interface MASWebSessionBrowserBasedAuthentication : NSObject <MASTypedBrowserBasedAuthenticationInterface>


///--------------------------------------
/// @name Lifecycle
///--------------------------------------

# pragma mark - Lifecycle

/**
* Initializer to perform default initialization.
*
* @param callbackURLScheme NSString containing the callback url scheme to use.
* @return Returns the newly initialized MASWebSessionBrowserBasedAuthentication.
*/
- (instancetype)initWithCallbackURLScheme:(NSString *)callbackURLScheme;
Copy link
Contributor

Choose a reason for hiding this comment

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

** Looks all good to me.
But had a bit of a hitch with taking an input for a custom url scheme from the customer.
I am coming from the perspective of 'its a SDK/Library', we might don't want to ask for the custom url scheme of the app.
What i am trying to see here is, we open the web login template on the ASWebAuthSession and upon the completion it redirects to the custom url scheme, this kicks the app re-opened again and the app delegate, delegates the callback url to the AuthResponse class. Is it possible through ASWebSession ??

Copy link
Author

Choose a reason for hiding this comment

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

I removed the need to provide the url scheme altogether for the WebSession browser authentication type. This will be extracted from the MSSO config.


@end



NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ @interface MASWebSessionBrowserBasedAuthentication()

@property (nonatomic, weak) id window;


@property (nonatomic, strong) NSString *callbackURLScheme;

@end

API_AVAILABLE(ios(13.0), macos(10.15))
Expand All @@ -39,16 +42,29 @@ @interface MASWebSessionBrowserBasedAuthentication() <ASWebAuthenticationPresent

@implementation MASWebSessionBrowserBasedAuthentication

///--------------------------------------
/// @name Lifecycle
///--------------------------------------

# pragma mark - Lifecycle

- (instancetype)initWithCallbackURLScheme:(NSString *)callbackURLScheme {
self = [super init];
self.callbackURLScheme = callbackURLScheme;

return self;
}


///--------------------------------------
/// @name Start & Stop
///--------------------------------------

# pragma mark - Start & Stop


- (void)startWithURL:(NSURL *)url completion:(MASAuthCredentialsBlock)webLoginBlock
{
self.session = [[ASWebAuthenticationSession alloc] initWithURL:url callbackURLScheme:nil completionHandler:^(NSURL * _Nullable callbackURL, NSError * _Nullable error) {
self.session = [[ASWebAuthenticationSession alloc] initWithURL:url callbackURLScheme:self.callbackURLScheme completionHandler:^(NSURL * _Nullable callbackURL, NSError * _Nullable error) {
if (callbackURL != nil) {
[MASAuthorizationResponse.sharedInstance handleAuthorizationResponseURL:callbackURL];
Copy link
Contributor

Choose a reason for hiding this comment

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

We came to this method through a custom scheme. We might need to evaluate if 'callbackURLScheme' could be used too.

Copy link
Author

@sandersaelmans sandersaelmans Dec 17, 2020

Choose a reason for hiding this comment

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

Good point. nil only works if it's the only url scheme a customer has specified in their URL types. I'll add a way for a customer to supply this parameter as well.

@ysd24: Do you have a preferred way to supply this? I can either:

  1. provide it via MAS -> MASModelService
  2. rewrite the the enum to some sort of configuration object which the user can provide.

Copy link
Author

Choose a reason for hiding this comment

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

@ysd24 updated PR so users an provide the call back url scheme when using a web session

} else {
Expand Down
12 changes: 6 additions & 6 deletions MASFoundation/Classes/_private_/services/model/MASModelService.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//

#import "MASService.h"

#import "MASBrowserBasedAuthenticationConfiguration.h"
#import "MASConstantsPrivate.h"


Expand Down Expand Up @@ -104,17 +104,17 @@
/**
* Sets the browser based authentication type property. Default is MASSafariBrowserBasedAuthenticationType.
*
* @param browserBasedAuthenticationType The type of browser used when invoking a browser based login.
* @param configuration MASBrowserBasedAuthenticationConfigurationInterface conforming object to configure the browser based authentication..
*/
+ (void)setBrowserBasedAuthenticationType:(MASBrowserBasedAuthenticationType)browserBasedAuthenticationType;
+ (void)setBrowserBasedAuthenticationConfiguration:(id<MASBrowserBasedAuthenticationConfigurationInterface>)configuration;


/**
* The current browser based authentication type.
* The current browser based authentication configuration.
*
* @return MASBrowserBasedAuthenticationType value is returned.
* @return MASBrowserBasedAuthenticationConfigurationInterface conforming object is returned.
*/
+ (MASBrowserBasedAuthenticationType)browserBasedAuthenticationType;
+ (id<MASBrowserBasedAuthenticationConfigurationInterface>)browserBasedAuthenticationConfiguration;


///--------------------------------------
Expand Down
14 changes: 9 additions & 5 deletions MASFoundation/Classes/_private_/services/model/MASModelService.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ @implementation MASModelService
static MASGrantFlow _grantFlow_ = MASGrantFlowClientCredentials;
static MASUserAuthCredentialsBlock _userAuthCredentialsBlock_ = nil;
static BOOL _isBrowserBasedAuthentication_ = NO;
static MASBrowserBasedAuthenticationType _browserBasedAuthenticationType_ = MASBrowserBasedAuthenticationTypeSafari;
static id<MASBrowserBasedAuthenticationConfigurationInterface> _browserBasedAuthenticationConfiguration_;

# pragma mark - Properties

Expand Down Expand Up @@ -87,15 +87,19 @@ + (BOOL)browserBasedAuthentication
}


+ (void)setBrowserBasedAuthenticationType:(MASBrowserBasedAuthenticationType)browserBasedAuthenticationType
+ (void)setBrowserBasedAuthenticationConfiguration:(id<MASBrowserBasedAuthenticationConfigurationInterface>)configuration
{
_browserBasedAuthenticationType_ = browserBasedAuthenticationType;
_browserBasedAuthenticationConfiguration_ = configuration;
}


+ (MASBrowserBasedAuthenticationType)browserBasedAuthenticationType
+ (id<MASBrowserBasedAuthenticationConfigurationInterface>)browserBasedAuthenticationConfiguration
{
return _browserBasedAuthenticationType_;
if (_browserBasedAuthenticationConfiguration_ == nil)
{
_browserBasedAuthenticationConfiguration_ = [[MASSafariBrowserBasedAuthenticationConfiguration alloc] init];
}
return _browserBasedAuthenticationConfiguration_;
}


Expand Down
4 changes: 2 additions & 2 deletions MASFoundation/Classes/models/MASBrowserBasedAuthentication.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ - (BOOL)redirectURLHasErrors :(NSURL*)redirectURL

- (void)launchBrowserWithURL:(NSURL*)templatizedURL
{
MASBrowserBasedAuthenticationType type = [MASModelService browserBasedAuthenticationType];
self.browser = [MASTypedBrowserBasedAuthenticationFactory buildBrowserForType:type];
id<MASBrowserBasedAuthenticationConfigurationInterface> configuration = [MASModelService browserBasedAuthenticationConfiguration];
self.browser = [MASTypedBrowserBasedAuthenticationFactory buildBrowserWithConfiguration:configuration];
[self.browser startWithURL:templatizedURL completion: self.webLoginCallBack];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// MASBrowserBasedAuthenticationConfigurationInterface.h
// MASFoundation
//
// Created by sander saelmans on 21/12/2020.
// Copyright © 2020 CA Technologies. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
MASBrowserBasedAuthenticationConfigurationInterface protocol is used to define a set of object which can be used to configure the preferred browser based authentication behaviour
*/
@protocol MASBrowserBasedAuthenticationConfigurationInterface <NSObject>
@end



/**
MASSafariBrowserBasedAuthenticationConfiguration class is used to present a SFSafariViewController browser based login
*/
@interface MASSafariBrowserBasedAuthenticationConfiguration : NSObject <MASBrowserBasedAuthenticationConfigurationInterface>

@end




API_AVAILABLE(ios(12.0), macCatalyst(13.0), macos(10.15), watchos(6.2)) API_UNAVAILABLE(tvos)
/**
MASSafariBrowserBasedAuthenticationConfiguration class is used to present a ASWebAuthenticationSession browser based login
@note You have to provide a valid callback url scheme in order for this configuration to work properly.
*/
@interface MASWebSessionBrowserBasedAuthenticationConfiguration : NSObject <MASBrowserBasedAuthenticationConfigurationInterface>


@property (nonatomic, strong, nonnull) NSString *callbackURLScheme;


/**
* Initialises a MASWebSessionBrowserBasedAuthenticationConfiguration with the provided callback url scheme
*
* @param callbackURLScheme Nonnull NSString object represeting the callback url scheme used to notify the login session has concluded.
* @return Returns an initialized MASWebSessionBrowserBasedAuthenticationConfiguration
*/
- (instancetype _Nonnull)initWithCallbackURLScheme:(NSString * _Nonnull)callbackURLScheme;


- (instancetype _Null_unspecified)init NS_UNAVAILABLE;


+ (instancetype _Null_unspecified)new NS_UNAVAILABLE;

@end
Loading