Skip to content

Commit 6329e71

Browse files
authored
Merge pull request #125 from AzureAD/jason/embeddedWebview
Embedded Webview
2 parents c6b1322 + e439cfc commit 6329e71

File tree

59 files changed

+3726
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3726
-122
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 228 additions & 22 deletions
Large diffs are not rendered by default.
File renamed without changes.

IdentityCore/src/MSIDContants.m renamed to IdentityCore/src/MSIDConstants.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
// THE SOFTWARE.
2323

24-
#import "MSIDContants.h"
24+
#import "MSIDConstants.h"
2525

2626
NSString *const MSID_PLATFORM_KEY = @"x-client-SKU";
2727
NSString *const MSID_VERSION_KEY = @"x-client-Ver";

IdentityCore/src/MSIDDeviceId.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#import "MSIDDeviceId.h"
2525
#import "MSIDVersion.h"
26-
#import "MSIDContants.h"
26+
#import "MSIDConstants.h"
2727
#import "MSIDOAuth2Constants.h"
2828

2929
#if !TARGET_OS_IPHONE

IdentityCore/src/MSIDError.h

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ typedef NS_ENUM(NSInteger, MSIDErrorCode)
7070
MSIDErrorInvalidGrant = -51016,
7171
MSIDErrorInvalidScope = -51017,
7272
MSIDErrorInvalidParameter = -51018,
73+
MSIDErrorUserCancel = -51019,
74+
/*!
75+
The authentication request was cancelled programmatically.
76+
*/
77+
MSIDErrorSessionCanceled = -51020,
78+
/*!
79+
An interactive authentication session is already running with the
80+
SafariViewController visible. Another authentication session can not be
81+
launched yet.
82+
*/
83+
MSIDErrorInteractiveSessionAlreadyRunning = -51021,
84+
/*!
85+
An interactive authentication session failed to start.
86+
*/
87+
MSIDErrorInteractiveSessionStartFailure = -51022,
88+
89+
MSIDErrorNoMainViewController = -51023,
90+
MSIDServerNonHttpsRedirect = -51024,
91+
92+
MSIDErrorUnsupportedFunctionality = -51025,
7393

7494
/*!
7595
The user or application failed to authenticate in the interactive flow.
@@ -78,43 +98,24 @@ typedef NS_ENUM(NSInteger, MSIDErrorCode)
7898
*/
7999
MSIDErrorAuthorizationFailed = -52020,
80100

81-
/*!
82-
The state returned by the server does not match the state that was sent to
83-
the server at the beginning of the authorization attempt.
84-
*/
85-
MSIDErrorInvalidState = -52501,
86101
/*!
87102
Interaction required errors occur because of a wide variety of errors
88103
returned by the authentication service.
89104
*/
90105
MSIDErrorMismatchedUser = -52101,
91106
MSIDErrorNoAuthorizationResponse = -52102,
92107
MSIDErrorBadAuthorizationResponse = -52103,
93-
94108

95-
MSIDErrorUserCancel = -51019,
96-
/*!
97-
The authentication request was cancelled programmatically.
98-
*/
99-
MSIDErrorSessionCanceled = -51020,
100-
/*!
101-
An interactive authentication session is already running with the
102-
SafariViewController visible. Another authentication session can not be
103-
launched yet.
104-
*/
105-
MSIDErrorInteractiveSessionAlreadyRunning = -51021,
106109
/*!
107-
An interactive authentication session failed to start.
110+
The state returned by the server does not match the state that was sent to
111+
the server at the beginning of the authorization attempt.
108112
*/
109-
MSIDErrorInteractiveSessionStartFailure = -51022,
110-
111-
MSIDErrorUnsupportedFunctionality = -51018,
113+
MSIDErrorInvalidState = -52501,
112114

113115
MSIDErrorCodeFirst = MSIDErrorInternal,
114-
MSIDErrorCodeLast = MSIDErrorUnsupportedFunctionality
116+
MSIDErrorCodeLast = MSIDErrorInvalidState
115117
};
116118

117119
extern NSError *MSIDCreateError(NSString *domain, NSInteger code, NSString *errorDescription, NSString *oauthError, NSString *subError, NSError *underlyingError, NSUUID *correlationId, NSDictionary *additionalUserInfo);
118120

119121
extern MSIDErrorCode MSIDErrorCodeForOAuthError(NSString *oauthError, MSIDErrorCode defaultCode);
120-

IdentityCore/src/configuration/webview/MSIDWebviewConfiguration.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
@property (readwrite) NSDictionary<NSString *, NSString *> *sliceParameters;
4444
@property (readwrite) NSString *promptBehavior;
4545
@property (readwrite) NSString *claims;
46+
@property (readwrite) NSDictionary<NSString *, NSString *> *customHeaders;
4647

4748
// State verifier: Recommended verifier for state value of the response.
4849
// Set to YES to stop if verifying state fails
@@ -59,6 +60,11 @@
5960
// Priority start URL
6061
@property (readwrite) NSURL *explicitStartURL;
6162

63+
#if TARGET_OS_IPHONE
64+
@property (weak) UIViewController *parentController;
65+
@property (readwrite)UIModalPresentationStyle presentationType;
66+
#endif
67+
6268
- (instancetype)initWithAuthorizationEndpoint:(NSURL *)authorizationEndpoint
6369
redirectUri:(NSString *)redirectUri
6470
clientId:(NSString *)clientId
@@ -68,5 +74,4 @@
6874
verifyState:(BOOL)verifyState
6975
enablePkce:(BOOL)enablePkce;
7076

71-
7277
@end

IdentityCore/src/network/request_configurator/MSIDAADRequestConfigurator.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#import "MSIDDeviceId.h"
3030
#import "NSDictionary+MSIDExtensions.h"
3131
#import "MSIDVersion.h"
32-
#import "MSIDContants.h"
32+
#import "MSIDConstants.h"
3333

3434
static NSTimeInterval const s_defaultTimeoutInterval = 300;
3535

IdentityCore/src/oauth2/MSIDOauth2Factory.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,5 +399,3 @@ - (MSIDWebviewFactory *)webviewFactory
399399
}
400400

401401
@end
402-
403-

IdentityCore/src/oauth2/MSIDWebviewFactory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@
5454
- (BOOL)verifyRequestState:(NSString *)requestState
5555
responseURL:(NSURL *)url
5656
error:(NSError **)error;
57+
- (NSString *)generateStateValue;
5758
@end

IdentityCore/src/oauth2/MSIDWebviewFactory.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,30 @@
2929
#import "MSIDSystemWebviewController.h"
3030
#import "MSIDPkce.h"
3131
#import "NSOrderedSet+MSIDExtensions.h"
32+
#import "MSIDOAuth2EmbeddedWebviewController.h"
3233

3334
@implementation MSIDWebviewFactory
3435

3536
#pragma mark - Webview creation
3637

3738
- (MSIDWebviewSession *)embeddedWebviewSessionFromConfiguration:(MSIDWebviewConfiguration *)configuration customWebview:(WKWebView *)webview context:(id<MSIDRequestContext>)context
3839
{
39-
return nil;
40+
NSString *state = [self generateStateValue];
41+
NSURL *startURL = [self startURLFromConfiguration:configuration requestState:state];
42+
NSURL *redirectURL = [NSURL URLWithString:configuration.redirectUri];
43+
44+
MSIDOAuth2EmbeddedWebviewController *embeddedWebviewController
45+
= [[MSIDOAuth2EmbeddedWebviewController alloc] initWithStartURL:startURL
46+
endURL:redirectURL
47+
webview:webview
48+
configuration:configuration
49+
context:context];
50+
51+
MSIDWebviewSession *session = [[MSIDWebviewSession alloc] initWithWebviewController:embeddedWebviewController
52+
factory:self
53+
requestState:state
54+
verifyState:configuration.verifyState];
55+
return session;
4056
}
4157

4258
#if TARGET_OS_IPHONE

0 commit comments

Comments
 (0)