-
Notifications
You must be signed in to change notification settings - Fork 19
Add option for user to select browser type to use for browser based authentication #265
base: develop
Are you sure you want to change the base?
Changes from 1 commit
7430418
553eb10
00dbbef
c14b271
75d6c76
ef25850
90fb3f4
65706bf
7fc8754
9ab0730
e43509b
f93934b
31c4231
8682e50
bc1d6b2
374c7b3
cecb20d
bdc0bad
1e6d309
6423696
9428327
ef20369
a2374bc
33158cf
6a2da19
7ee1716
b492e32
7c48c43
4e6029d
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 |
---|---|---|
|
@@ -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)) | ||
|
@@ -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]; | ||
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. We came to this method through a custom scheme. We might need to evaluate if 'callbackURLScheme' could be used too. 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. Good point. @ysd24: Do you have a preferred way to supply this? I can either:
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. @ysd24 updated PR so users an provide the call back url scheme when using a web session |
||
} else { | ||
|
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 |
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.
** 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 ??
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.
I removed the need to provide the url scheme altogether for the WebSession browser authentication type. This will be extracted from the MSSO config.