Skip to content

Commit 86cd8e9

Browse files
authored
Merge pull request #1506 from AzureAD/release/2.7.17
Release ADAL 2.7.17
2 parents 268d5f1 + 54bd914 commit 86cd8e9

20 files changed

+298
-21
lines changed

ADAL.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "ADAL"
33
s.module_name = "ADAL"
4-
s.version = "2.7.16"
4+
s.version = "2.7.17"
55
s.summary = "The ADAL SDK for iOS gives you the ability to add Azure Identity authentication to your application"
66

77
s.description = <<-DESC

ADAL/ADAL.xcodeproj/project.pbxproj

+8
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@
363363
B2BA4960208BFDA800CE92FC /* ADALAuthorityMigrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2BA495F208BFDA800CE92FC /* ADALAuthorityMigrationTests.m */; };
364364
B2BA4962208C009F00CE92FC /* ADALClaimsChallengeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2BA4961208C009F00CE92FC /* ADALClaimsChallengeTests.m */; };
365365
B2BA4964208C1F6700CE92FC /* ADALOnPremLoginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2BA4963208C1F6700CE92FC /* ADALOnPremLoginTests.m */; };
366+
B2C0E7E623AED0AA006C9CAD /* ADTestBundle.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C0E7E523AED0AA006C9CAD /* ADTestBundle.m */; };
367+
B2C0E7E723AED0AA006C9CAD /* ADTestBundle.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C0E7E523AED0AA006C9CAD /* ADTestBundle.m */; };
366368
B2CD211620632C09009869D5 /* GSS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2CD211520632C09009869D5 /* GSS.framework */; };
367369
B2D184192082F2940001D445 /* libIdentityCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D626FFC81FBD1B1300EE4487 /* libIdentityCore.a */; };
368370
B2D1841B208335300001D445 /* ADALUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2D1841A208335300001D445 /* ADALUITests.swift */; };
@@ -1193,6 +1195,8 @@
11931195
B2BA495F208BFDA800CE92FC /* ADALAuthorityMigrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ADALAuthorityMigrationTests.m; sourceTree = "<group>"; };
11941196
B2BA4961208C009F00CE92FC /* ADALClaimsChallengeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ADALClaimsChallengeTests.m; sourceTree = "<group>"; };
11951197
B2BA4963208C1F6700CE92FC /* ADALOnPremLoginTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ADALOnPremLoginTests.m; sourceTree = "<group>"; };
1198+
B2C0E7E023AED0AA006C9CAD /* ADTestBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADTestBundle.h; sourceTree = "<group>"; };
1199+
B2C0E7E523AED0AA006C9CAD /* ADTestBundle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADTestBundle.m; sourceTree = "<group>"; };
11961200
B2CD211520632C09009869D5 /* GSS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GSS.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/GSS.framework; sourceTree = DEVELOPER_DIR; };
11971201
B2D1841A208335300001D445 /* ADALUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADALUITests.swift; sourceTree = "<group>"; };
11981202
B2D32CF820E9C317002C39AD /* StressIOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StressIOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -2380,6 +2384,8 @@
23802384
D6771E051F74A4D200D0DCDC /* ios */ = {
23812385
isa = PBXGroup;
23822386
children = (
2387+
B2C0E7E023AED0AA006C9CAD /* ADTestBundle.h */,
2388+
B2C0E7E523AED0AA006C9CAD /* ADTestBundle.m */,
23832389
A521AB7220EED8AC0005735B /* ADEnrollmentGateway+TestUtil.m */,
23842390
A521AB6F20EEC34C0005735B /* ADEnrollmentGateway+TestUtil.h */,
23852391
D6771E011F749FD800D0DCDC /* ADApplicationTestUtil.h */,
@@ -3508,6 +3514,7 @@
35083514
B20DC5F91F0D998A00957806 /* ADHelpersTests.m in Sources */,
35093515
B20DC6071F0D998A00957806 /* ADWebAuthResponseTests.m in Sources */,
35103516
B20DC5F51F0D998A00957806 /* ADAuthenticationResultTests.m in Sources */,
3517+
B2C0E7E623AED0AA006C9CAD /* ADTestBundle.m in Sources */,
35113518
232ED2BA20083F7800C5D74A /* ADBrokerHelperTests.m in Sources */,
35123519
B20DC61D1F0DA39C00957806 /* ADBrokerKeyHelperTests.m in Sources */,
35133520
B20DC61F1F0DA3C500957806 /* ADKeychainTokenCacheTests.m in Sources */,
@@ -3683,6 +3690,7 @@
36833690
buildActionMask = 2147483647;
36843691
files = (
36853692
236BF3FF205B38EB006E3897 /* ADAcquireTokenPkeyAuthTests.m in Sources */,
3693+
B2C0E7E723AED0AA006C9CAD /* ADTestBundle.m in Sources */,
36863694
D67D3D3C1F38502900660F32 /* ADTestCase.m in Sources */,
36873695
B29A36CF20B1333200427B63 /* ADBrokerIntegrationTests.m in Sources */,
36883696
B24D25F9205EFBC200025B8B /* ADAuthenticationErrorConverterIntegrationTests.m in Sources */,

ADAL/resources/ios/Framework/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.7.16</string>
18+
<string>2.7.17</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

ADAL/resources/mac/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.7.15</string>
18+
<string>2.7.17</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

ADAL/src/ADALConstants.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ extern NSString* const ADAL_BROKER_SCHEME;
5050
extern NSString* const ADAL_BROKER_NONCE_SCHEME;
5151
extern NSString* const ADAL_BROKER_APP_REDIRECT_URI;
5252
extern NSString* const ADAL_BROKER_APP_BUNDLE_ID;
53-
53+
extern NSString* const ADAL_BROKER_APP_BUNDLE_ID_DOGFOOD;

ADAL/src/ADALConstants.m

+1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@
5252
NSString* const ADAL_BROKER_NONCE_SCHEME = @"msauthv3";
5353
NSString* const ADAL_BROKER_APP_REDIRECT_URI = @"urn:ietf:wg:oauth:2.0:oob";
5454
NSString* const ADAL_BROKER_APP_BUNDLE_ID = @"com.microsoft.azureauthenticator";
55+
NSString* const ADAL_BROKER_APP_BUNDLE_ID_DOGFOOD = @"com.microsoft.azureauthenticator-df";
5556

ADAL/src/ADAL_Internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// through build script. Don't change its format unless changing build script as well.)
2828
#define ADAL_VER_HIGH 2
2929
#define ADAL_VER_LOW 7
30-
#define ADAL_VER_PATCH 16
30+
#define ADAL_VER_PATCH 17
3131

3232
#define STR_HELPER(x) #x
3333
#define STR(x) STR_HELPER(x)

ADAL/src/ADAuthenticationContext+Internal.m

+2-5
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,8 @@ + (BOOL)canHandleResponse:(NSURL *)response
215215
+ (BOOL)isResponseFromBroker:(NSString *)sourceApplication
216216
response:(NSURL *)response
217217
{
218-
BOOL isBroker = [sourceApplication isEqualToString:ADAL_BROKER_APP_BUNDLE_ID];
219-
220-
#ifdef DOGFOOD_BROKER
221-
isBroker = isBroker || [sourceApplication isEqualToString:ADAL_BROKER_APP_BUNDLE_ID_DOGFOOD];
222-
#endif
218+
BOOL isBroker = [sourceApplication isEqualToString:ADAL_BROKER_APP_BUNDLE_ID]
219+
|| [sourceApplication isEqualToString:ADAL_BROKER_APP_BUNDLE_ID_DOGFOOD];
223220

224221
return response && isBroker;
225222
}

ADAL/src/request/ADAuthenticationRequest+AcquireToken.m

+20-8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#import "MSIDADFSAuthority.h"
4848
#import "MSIDAuthorityFactory.h"
4949
#import "MSIDClientCapabilitiesUtil.h"
50+
#import "ADAuthenticationErrorConverter.h"
5051

5152
@implementation ADAuthenticationRequest (AcquireToken)
5253

@@ -149,15 +150,26 @@ - (void)acquireToken:(NSString *)apiId
149150
return;
150151
}
151152

152-
if (!_silent && _context.credentialsType == AD_CREDENTIALS_AUTO && ![ADAuthenticationRequest validBrokerRedirectUri:_requestParams.redirectUri])
153+
if (!_silent && _context.credentialsType == AD_CREDENTIALS_AUTO)
153154
{
154-
ADAuthenticationError* error =
155-
[ADAuthenticationError errorFromAuthenticationError:AD_ERROR_TOKENBROKER_INVALID_REDIRECT_URI
156-
protocolCode:nil
157-
errorDetails:ADRedirectUriInvalidError
158-
correlationId:_requestParams.correlationId];
159-
wrappedCallback([ADAuthenticationResult resultFromError:error correlationId:_requestParams.correlationId]);
160-
return;
155+
if (![ADAuthenticationRequest validBrokerRedirectUri:_requestParams.redirectUri])
156+
{
157+
ADAuthenticationError* error =
158+
[ADAuthenticationError errorFromAuthenticationError:AD_ERROR_TOKENBROKER_INVALID_REDIRECT_URI
159+
protocolCode:nil
160+
errorDetails:ADRedirectUriInvalidError
161+
correlationId:_requestParams.correlationId];
162+
wrappedCallback([ADAuthenticationResult resultFromError:error correlationId:_requestParams.correlationId]);
163+
return;
164+
}
165+
166+
NSError *msidError;
167+
if (![ADAuthenticationRequest verifyAdditionalRequiredSchemesAreRegistered:&msidError correlationID:_requestParams.correlationId])
168+
{
169+
ADAuthenticationError *error = [ADAuthenticationErrorConverter ADAuthenticationErrorFromMSIDError:msidError];
170+
wrappedCallback([ADAuthenticationResult resultFromError:error correlationId:_requestParams.correlationId]);
171+
return;
172+
}
161173
}
162174

163175
[[MSIDTelemetry sharedInstance] startEvent:telemetryRequestId eventName:MSID_TELEMETRY_EVENT_AUTHORITY_VALIDATION];

ADAL/src/request/ADAuthenticationRequest+Broker.h

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ extern NSString *kAdalSDKObjc;
3535

3636
+ (BOOL)validBrokerRedirectUri:(NSString *)url;
3737

38+
+ (BOOL)verifyAdditionalRequiredSchemesAreRegistered:(NSError **)error
39+
correlationID:(NSUUID *)correlationID;
40+
3841
- (BOOL)canUseBroker;
3942

4043
- (NSURL *)composeBrokerRequest:(ADAuthenticationError * __autoreleasing *)error;

ADAL/src/request/ADAuthenticationRequest+Broker.m

+27
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,33 @@ + (BOOL)validBrokerRedirectUri:(NSString*)url
109109
return NO;
110110
}
111111

112+
+ (BOOL)verifyAdditionalRequiredSchemesAreRegistered:(NSError **)error
113+
correlationID:(NSUUID *)correlationID
114+
{
115+
NSArray *querySchemes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"LSApplicationQueriesSchemes"];
116+
117+
BOOL containsRequiredSchemes = [querySchemes containsObject:ADAL_BROKER_SCHEME];
118+
119+
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
120+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
121+
containsRequiredSchemes &= [querySchemes containsObject:ADAL_BROKER_NONCE_SCHEME];
122+
#endif
123+
#endif
124+
125+
if (!containsRequiredSchemes)
126+
{
127+
if (error)
128+
{
129+
NSString *message = @"The required query schemes \"msauth\" and \"msauthv3\" are not registered in the app's info.plist file. Please add \"msauth\" and \"msauthv3\" into Info.plist under LSApplicationQueriesSchemes without any whitespaces.";
130+
*error = MSIDCreateError(MSIDErrorDomain, MSIDErrorInvalidDeveloperParameter, message, nil, nil, nil, correlationID, nil);
131+
}
132+
133+
return NO;
134+
}
135+
136+
return YES;
137+
}
138+
112139
/*!
113140
Process the broker response and call the completion block, if it is available.
114141

ADAL/src/ui/ios/ADAuthenticationViewController.m

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ @interface ADAuthenticationViewController ( ) <UIWebViewDelegate>
3939
id _foregroundObserver;
4040
}
4141

42+
@property (nonatomic) BOOL presentInParentController;
43+
4244
@end
4345

4446
@implementation ADAuthenticationViewController
@@ -62,6 +64,7 @@ - (BOOL)loadView:(ADAuthenticationError * __autoreleasing *)error
6264
// hijack the delegate on the webview.
6365
if (_webView)
6466
{
67+
self.presentInParentController = NO;
6568
_webView.delegate = self;
6669
return YES;
6770
}
@@ -107,6 +110,8 @@ - (BOOL)loadView:(ADAuthenticationError * __autoreleasing *)error
107110
target:self
108111
action:@selector(onCancel:)];
109112
self.navigationItem.leftBarButtonItem = cancelButton;
113+
114+
self.presentInParentController = YES;
110115

111116
return YES;
112117
}
@@ -137,7 +142,7 @@ - (void)stop:(void (^)(void))completion
137142

138143
//if webview is created by us, dismiss and then complete and return;
139144
//otherwise just complete and return.
140-
if (_parentController)
145+
if (_parentController && self.presentInParentController)
141146
{
142147
if (_parentController.parentViewController && _parentController.presentedViewController)
143148
{
@@ -161,6 +166,8 @@ - (void)stop:(void (^)(void))completion
161166
- (void)startRequest:(NSURLRequest *)request
162167
{
163168
[self loadRequest:request];
169+
170+
if (!self.presentInParentController) return;
164171

165172
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self];
166173

ADAL/tests/app/resources/ios/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.7.16</string>
18+
<string>2.7.17</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleURLTypes</key>

ADAL/tests/app/src/ios/ADTestAppAcquireTokenViewController.m

+1
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ - (void)acquireTokenInteractive:(id)sender
644644
validateAuthority:validateAuthority
645645
error:&error];
646646
context.clientCapabilities = capabilities;
647+
context.parentController = self;
647648

648649
if (!context)
649650
{

ADAL/tests/integration/ios/ADBrokerIntegrationTests.m

+37
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#import "ADTokenCacheItem+Internal.h"
5151
#import "NSDictionary+MSIDTestUtil.h"
5252
#import "ADBrokerApplicationTokenHelper.h"
53+
#import "ADTestBundle.h"
5354

5455
@interface ADEnrollmentGateway ()
5556

@@ -69,6 +70,8 @@ - (void)setUp
6970
[super setUp];
7071

7172
[MSIDKeychainTokenCache reset];
73+
NSArray *urlSchemes = @[@"msauth", @"msauthv3"];
74+
[ADTestBundle overrideObject:urlSchemes forKey:@"LSApplicationQueriesSchemes"];
7275
}
7376

7477
- (void)tearDown
@@ -78,6 +81,40 @@ - (void)tearDown
7881

7982
#pragma mark - Tests
8083

84+
- (void)testBroker_whenMSAuthV3SchemeIsNotRegistered_shouldReturnError_andNotInvokeBroker
85+
{
86+
XCTestExpectation *openURLExpectation = [self expectationWithDescription:@"Open URL"];
87+
openURLExpectation.inverted = YES;
88+
89+
[ADApplicationTestUtil onOpenURL:^BOOL(__unused NSURL *url, __unused NSDictionary<NSString *,id> *options) {
90+
[openURLExpectation fulfill];
91+
return YES;
92+
}];
93+
94+
NSArray *urlSchemes = @[@"msauth-wrong", @"msauthv3"];
95+
[ADTestBundle overrideObject:urlSchemes forKey:@"LSApplicationQueriesSchemes"];
96+
97+
NSString *authority = @"https://login.windows.net/common";
98+
NSString *redirectUri = @"x-msauth-unittest://com.microsoft.unittesthost";
99+
ADAuthenticationContext *context = [self getBrokerTestContext:authority];
100+
101+
XCTestExpectation *expectation = [self expectationWithDescription:@"acquire token callback"];
102+
[context acquireTokenWithResource:TEST_RESOURCE
103+
clientId:TEST_CLIENT_ID
104+
redirectUri:[NSURL URLWithString:redirectUri]
105+
completionBlock:^(ADAuthenticationResult *result)
106+
{
107+
XCTAssertNotNil(result);
108+
XCTAssertEqual(result.status, AD_FAILED);
109+
110+
XCTAssertEqualObjects(result.error.domain, ADAuthenticationErrorDomain);
111+
XCTAssertEqual(result.error.code, AD_ERROR_DEVELOPER_INVALID_ARGUMENT);
112+
[expectation fulfill];
113+
}];
114+
115+
[self waitForExpectations:@[expectation, openURLExpectation] timeout:1.0];
116+
}
117+
81118
- (void)testBroker_whenSimpleAcquireToken_andSourceApplicationNonNil_andNonceMissingInBrokerResponse_shouldSucceed
82119
{
83120
NSString *authority = @"https://login.windows.net/common";

ADAL/tests/util/ios/ADTestBundle.h

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//------------------------------------------------------------------------------
2+
//
3+
// Copyright (c) Microsoft Corporation.
4+
// All rights reserved.
5+
//
6+
// This code is licensed under the MIT License.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files(the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions :
14+
//
15+
// The above copyright notice and this permission notice shall be included in
16+
// all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
// THE SOFTWARE.
25+
//
26+
//------------------------------------------------------------------------------
27+
28+
#import <Foundation/Foundation.h>
29+
30+
/*!
31+
This class allows tests to override values returned by various NSBundle
32+
methods. It is automatically reset at the beginning of each test case in
33+
subclasses of MSALTestCase.
34+
*/
35+
36+
@interface ADTestBundle : NSObject
37+
38+
+ (void)reset;
39+
40+
/*!
41+
Objects set with this method will override values returned by -[NSBundle
42+
objectForInfoDictionaryKey:]
43+
*/
44+
+ (void)overrideObject:(id)object
45+
forKey:(NSString *)key;
46+
47+
/*!
48+
Overrides the string returned by -[NSBundle bundleIdentifier]
49+
*/
50+
+ (void)overrideBundleId:(NSString *)bundleId;
51+
52+
@end

0 commit comments

Comments
 (0)