Skip to content

Commit bb1d57b

Browse files
Merge pull request #1485 from AzureAD/release/1.9.0
Release/1.9.0
2 parents 6091460 + ad115f9 commit bb1d57b

File tree

79 files changed

+2526
-810
lines changed

Some content is hidden

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

79 files changed

+2526
-810
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

+117-21
Large diffs are not rendered by default.

IdentityCore/src/MSIDBrokerConstants.h

-2
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,3 @@ extern NSString * _Nonnull const MSID_CREATE_NEW_URL_SESSION;
104104
extern NSString * _Nonnull const MSID_HTTP_CONNECTION_VALUE;
105105
extern NSString * _Nonnull const MSID_FORCE_REFRESH_KEY;
106106

107-
extern BOOL MSID_SUPPRESS_CAMERA_CONSENT_PROMPT_IN_WEBVIEW;
108-

IdentityCore/src/MSIDBrokerConstants.m

-3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,3 @@
104104
// Http header
105105
NSString *const MSID_HTTP_CONNECTION = @"Connection";
106106
NSString *const MSID_HTTP_CONNECTION_VALUE = @"close";
107-
108-
// Non-constant
109-
BOOL MSID_SUPPRESS_CAMERA_CONSENT_PROMPT_IN_WEBVIEW = NO;

IdentityCore/src/MSIDConstants.h

+6
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,10 @@ typedef NS_ENUM(NSInteger, MSIDPlatformSequenceIndex)
171171
MSIDPlatformSequenceIndexLast = MSIDPlatformSequenceIndexBrowserCore,
172172
};
173173

174+
extern NSString * _Nonnull const MSID_BROWSER_RESPONSE_SWITCH_BROWSER;
175+
extern NSString * _Nonnull const MSID_BROWSER_RESPONSE_SWITCH_BROWSER_RESUME;
176+
177+
extern NSString * _Nonnull const MSID_FLIGHT_USE_V2_WEB_RESPONSE_FACTORY;
178+
extern NSString * _Nonnull const MSID_FLIGHT_SUPPORT_DUNA_CBA;
179+
174180
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]

IdentityCore/src/MSIDConstants.m

+7
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,11 @@
7373

7474
NSString *const MSID_BROWSER_NATIVE_MESSAGE_ACCOUNT_ID_KEY = @"accountId";
7575

76+
NSString *const MSID_BROWSER_RESPONSE_SWITCH_BROWSER = @"switch_browser";
77+
NSString *const MSID_BROWSER_RESPONSE_SWITCH_BROWSER_RESUME = @"switch_browser_resume";
78+
79+
NSString *const MSID_FLIGHT_USE_V2_WEB_RESPONSE_FACTORY = @"use_v2_web_response_factory";
80+
NSString *const MSID_FLIGHT_SUPPORT_DUNA_CBA = @"support_duna_cba";
81+
82+
7683
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//
12
// Copyright (c) Microsoft Corporation.
23
// All rights reserved.
34
//
@@ -19,29 +20,25 @@
1920
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2021
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2122
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22-
// THE SOFTWARE.
23+
// THE SOFTWARE.
24+
2325

24-
#ifndef MSIDCertAuthHandler_iOS_h
25-
#define MSIDCertAuthHandler_iOS_h
26+
#import <Foundation/Foundation.h>
2627

27-
#import "MSIDCertAuthHandler.h"
28+
NS_ASSUME_NONNULL_BEGIN
2829

29-
@interface MSIDCertAuthHandler (iOS)
30+
@protocol MSIDFlightManagerInterface <NSObject>
3031

31-
#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV
32+
- (BOOL)boolForKey:(NSString *)flightKey;
3233

33-
+ (void)setRedirectUriPrefix:(NSString *)prefix
34-
forScheme:(NSString *)scheme;
34+
@end
3535

36-
+ (void)setUseAuthSession:(BOOL)useAuthSession;
37-
+ (void)setUseLastRequestURL:(BOOL)useLastRequestURL;
36+
@interface MSIDFlightManager : NSObject <MSIDFlightManagerInterface>
3837

39-
// These are for cert auth challenge for iOS
40-
+ (void)setCustomActivities:(NSArray<UIActivity *> *)activities;
41-
+ (BOOL)completeCertAuthChallenge:(NSURL *)endUrl;
42-
+ (BOOL)isCertAuthInProgress;
38+
@property (nonatomic) id<MSIDFlightManagerInterface> flightProvider;
4339

44-
#endif
40+
+ (instancetype)sharedInstance;
4541

4642
@end
47-
#endif /* MSIDCertAuthHandler_mac_h */
43+
44+
NS_ASSUME_NONNULL_END

IdentityCore/src/MSIDFlightManager.m

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// Copyright (c) Microsoft Corporation.
3+
// All rights reserved.
4+
//
5+
// This code is licensed under the MIT License.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files(the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions :
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
26+
#import "MSIDFlightManager.h"
27+
28+
@implementation MSIDFlightManager
29+
30+
+ (instancetype)sharedInstance
31+
{
32+
static MSIDFlightManager *sharedInstance = nil;
33+
static dispatch_once_t onceToken;
34+
dispatch_once(&onceToken, ^{
35+
sharedInstance = [[self.class alloc] init];
36+
});
37+
38+
return sharedInstance;
39+
}
40+
41+
#pragma mark - MSIDFlightManagerInterface
42+
43+
- (BOOL)boolForKey:(nonnull NSString *)flightKey
44+
{
45+
if (self.flightProvider) { return [self.flightProvider boolForKey:flightKey]; }
46+
47+
return NO;
48+
}
49+
50+
@end

IdentityCore/src/broker_operation/response/MSIDBrokerNativeAppOperationResponse.h

-9
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ NS_ASSUME_NONNULL_BEGIN
5353
- (instancetype)init NS_UNAVAILABLE;
5454
+ (instancetype)new NS_UNAVAILABLE;
5555

56-
#if !EXCLUDE_FROM_MSALCPP
57-
58-
- (void)trackPerfTelemetryWithLastRequest:(MSIDLastRequestTelemetry *)telemetry
59-
requestStartDate:(NSDate *)requestStartDate
60-
telemetryType:(NSString *)telemetryType;
61-
62-
#endif
63-
64-
6556
@end
6657

6758
NS_ASSUME_NONNULL_END

IdentityCore/src/broker_operation/response/MSIDBrokerNativeAppOperationResponse.m

-25
Original file line numberDiff line numberDiff line change
@@ -124,29 +124,4 @@ - (NSDictionary *)jsonDictionary
124124
return json;
125125
}
126126

127-
#if !EXCLUDE_FROM_MSALCPP
128-
129-
- (void)trackPerfTelemetryWithLastRequest:(MSIDLastRequestTelemetry *)telemetry
130-
requestStartDate:(NSDate *)requestStartDate
131-
telemetryType:(NSString *)telemetryType
132-
{
133-
if (!requestStartDate)
134-
{
135-
MSID_LOG_WITH_CTX(MSIDLogLevelError, nil, @"trackPerfTelemetryWithLastRequest called with nil request start date");
136-
return;
137-
}
138-
139-
NSDate *responseDate = [NSDate date];
140-
NSTimeInterval totalTime = [responseDate timeIntervalSinceDate:requestStartDate];
141-
NSTimeInterval ipcRequestTime = self.requestReceivedTimeStamp ? [self.requestReceivedTimeStamp timeIntervalSinceDate:requestStartDate] : 0;
142-
NSTimeInterval ipcResponseTime = self.responseGenerationTimeStamp ? [responseDate timeIntervalSinceDate:self.responseGenerationTimeStamp] : 0;
143-
144-
[telemetry trackSSOExtensionPerformanceWithType:telemetryType
145-
totalPerfNumber:totalTime
146-
ipcRequestPerfNumber:ipcRequestTime
147-
ipcResponsePerfNumber:ipcResponseTime];
148-
}
149-
150-
#endif
151-
152127
@end

IdentityCore/src/configuration/webview/MSIDAuthorizeWebRequestConfiguration.m

+5-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ - (MSIDWebviewResponse *)responseWithResultURL:(NSURL *)url
5858
error:(NSError *__autoreleasing*)error
5959
{
6060
return [factory oAuthResponseWithURL:url
61-
requestState:self.state
62-
ignoreInvalidState:self.ignoreInvalidState
63-
context:context
64-
error:error];
61+
requestState:self.state
62+
ignoreInvalidState:self.ignoreInvalidState
63+
endRedirectUri:self.endRedirectUrl
64+
context:context
65+
error:error];
6566
}
6667

6768
@end

IdentityCore/src/network/request_server_telemetry/MSIDAADTokenRequestServerTelemetry.m

+6-10
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,22 @@ - (void)handleError:(nullable NSError *)error
5151
context:(id<MSIDRequestContext>)context
5252
{
5353
if (error == nil) {
54-
MSID_LOG_WITH_CTX(MSIDLogLevelError, context, @"Failed to handle telemetry. Error is nil");
55-
return;
54+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"Error is nil, reset MSID telemetry");
5655
}
5756

58-
NSString *errorString = [error msidServerTelemetryErrorString];
59-
60-
[self handleError:error
61-
errorString:errorString
62-
context:context];
57+
[self.lastRequestTelemetry updateWithApiId:self.currentRequestTelemetry.apiId
58+
errorString:[error msidServerTelemetryErrorString]
59+
context:context];
6360
}
6461

6562
- (void)handleError:(nullable NSError *)error
6663
errorString:(NSString *)errorString
6764
context:(id<MSIDRequestContext>)context
6865
{
6966
if (error == nil) {
70-
MSID_LOG_WITH_CTX(MSIDLogLevelError, context, @"Failed to handle telemetry. Error is nil");
71-
return;
67+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"Error is nil, reset MSID telemetry");
7268
}
73-
69+
7470
[self.lastRequestTelemetry updateWithApiId:self.currentRequestTelemetry.apiId
7571
errorString:errorString
7672
context:context];

IdentityCore/src/oauth2/MSIDWebviewFactory.h

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
- (MSIDWebviewResponse *)oAuthResponseWithURL:(NSURL *)url
7575
requestState:(NSString *)requestState
7676
ignoreInvalidState:(BOOL)ignoreInvalidState
77+
endRedirectUri:(NSString *)endRedirectUri
7778
context:(id<MSIDRequestContext>)context
7879
error:(NSError *__autoreleasing*)error;
7980

IdentityCore/src/oauth2/MSIDWebviewFactory.m

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ @implementation MSIDWebviewFactory
242242
- (MSIDWebviewResponse *)oAuthResponseWithURL:(NSURL *)url
243243
requestState:(NSString *)requestState
244244
ignoreInvalidState:(BOOL)ignoreInvalidState
245+
endRedirectUri:(NSString *)endRedirectUri
245246
context:(id<MSIDRequestContext>)context
246247
error:(NSError *__autoreleasing*)error
247248
{

IdentityCore/src/oauth2/aad_base/MSIDAADWebviewFactory.m

+31-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#import "MSIDSignoutWebRequestConfiguration.h"
3939
#import "NSURL+MSIDAADUtils.h"
4040
#import "MSIDInteractiveTokenRequestParameters.h"
41+
#import "MSIDSwitchBrowserResponse.h"
42+
#import "MSIDSwitchBrowserResumeResponse.h"
43+
#import "MSIDFlightManager.h"
4144

4245
#if !EXCLUDE_FROM_MSALCPP
4346
#import "MSIDJITTroubleshootingResponse.h"
@@ -73,14 +76,22 @@ @implementation MSIDAADWebviewFactory
7376
{
7477
[result addEntriesFromDictionary:
7578
@{
76-
MSID_OAUTH2_CORRELATION_ID_REQUEST : @"true",
77-
MSID_OAUTH2_CORRELATION_ID_REQUEST_VALUE : [parameters.correlationId UUIDString]
78-
}];
79+
MSID_OAUTH2_CORRELATION_ID_REQUEST : @"true",
80+
MSID_OAUTH2_CORRELATION_ID_REQUEST_VALUE : [parameters.correlationId UUIDString]
81+
}];
7982
}
8083

8184
result[@"haschrome"] = @"1";
8285
[result addEntriesFromDictionary:MSIDDeviceId.deviceId];
8386

87+
#if TARGET_OS_IPHONE
88+
if ([MSIDFlightManager.sharedInstance boolForKey:MSID_FLIGHT_SUPPORT_DUNA_CBA])
89+
{
90+
// Let server know that we support new cba flow
91+
result[MSID_BROWSER_RESPONSE_SWITCH_BROWSER] = @"1";
92+
}
93+
#endif
94+
8495
return result;
8596
}
8697

@@ -139,6 +150,7 @@ @implementation MSIDAADWebviewFactory
139150
- (MSIDWebviewResponse *)oAuthResponseWithURL:(NSURL *)url
140151
requestState:(NSString *)requestState
141152
ignoreInvalidState:(BOOL)ignoreInvalidState
153+
endRedirectUri:(NSString *)endRedirectUri
142154
context:(id<MSIDRequestContext>)context
143155
error:(NSError *__autoreleasing*)error
144156
{
@@ -190,7 +202,22 @@ - (MSIDWebviewResponse *)oAuthResponseWithURL:(NSURL *)url
190202
error:nil];
191203
if (browserResponse) return browserResponse;
192204

193-
// Try to create AAD Auth response
205+
if ([MSIDFlightManager.sharedInstance boolForKey:MSID_FLIGHT_SUPPORT_DUNA_CBA])
206+
{
207+
MSIDSwitchBrowserResponse *switchBrowserResponse = [[MSIDSwitchBrowserResponse alloc] initWithURL:url
208+
redirectUri:endRedirectUri
209+
context:context
210+
error:nil];
211+
if (switchBrowserResponse) return switchBrowserResponse;
212+
213+
MSIDSwitchBrowserResumeResponse *switchBrowserResumeResponse = [[MSIDSwitchBrowserResumeResponse alloc] initWithURL:url
214+
redirectUri:endRedirectUri
215+
context:context
216+
error:nil];
217+
if (switchBrowserResumeResponse) return switchBrowserResumeResponse;
218+
}
219+
220+
// Try to create AAD Auth response or Error response (all other reponses don't handle errors).
194221
MSIDWebAADAuthCodeResponse *response = [[MSIDWebAADAuthCodeResponse alloc] initWithURL:url
195222
requestState:requestState
196223
ignoreInvalidState:ignoreInvalidState

0 commit comments

Comments
 (0)