Skip to content

Commit 6e1b41b

Browse files
authored
Merge pull request #905 from AzureAD/release/1.6.0
Release 1.6.0
2 parents cb25157 + a95981a commit 6e1b41b

36 files changed

+486
-69
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ before_script:
1111
- set -o pipefail
1212

1313
script:
14+
- python ./scripts/update_xcode_config_cpp_checks.py
1415
- ./build.py --no-clean --show-build-settings
1516

1617
after_failure:

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@
558558
6E4F658F24D4883A0070CA36 /* MSIDSymmetricKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E4F658D24D4883A0070CA36 /* MSIDSymmetricKey.m */; };
559559
6E4F659324D48B630070CA36 /* MSIDSymmetricKeyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E4F659024D48B120070CA36 /* MSIDSymmetricKeyTests.m */; };
560560
6E4F659424D48B6D0070CA36 /* MSIDSymmetricKeyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E4F659024D48B120070CA36 /* MSIDSymmetricKeyTests.m */; };
561+
720AC2A72550D4FB00B2C7C8 /* MSIDAppExtensionUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 720AC2A62550D4FB00B2C7C8 /* MSIDAppExtensionUtil.m */; };
561562
740340B92460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 740340B72460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.h */; };
562563
740340BA2460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 740340B82460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.m */; };
563564
740340BB2460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 740340B82460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.m */; };
@@ -2171,6 +2172,7 @@
21712172
6E4F658B24D488010070CA36 /* MSIDSymmetricKey.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDSymmetricKey.h; sourceTree = "<group>"; };
21722173
6E4F658D24D4883A0070CA36 /* MSIDSymmetricKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDSymmetricKey.m; sourceTree = "<group>"; };
21732174
6E4F659024D48B120070CA36 /* MSIDSymmetricKeyTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDSymmetricKeyTests.m; sourceTree = "<group>"; };
2175+
720AC2A62550D4FB00B2C7C8 /* MSIDAppExtensionUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDAppExtensionUtil.m; sourceTree = "<group>"; };
21742176
740340B72460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDCurrentRequestTelemetrySerializedItem.h; sourceTree = "<group>"; };
21752177
740340B82460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDCurrentRequestTelemetrySerializedItem.m; sourceTree = "<group>"; };
21762178
74043F7C245CC84B00D3E7C1 /* MSIDCurrentRequestTelemetryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDCurrentRequestTelemetryTests.m; sourceTree = "<group>"; };
@@ -3002,6 +3004,7 @@
30023004
B28686C024065441004E83FC /* MSIDLoginKeychainUtil.m */,
30033005
B2AE0FDC2427E9FC00B8FAF1 /* MSIDKeychainUtil+MacInternal.h */,
30043006
583BFCAA24D88CED0035B901 /* MSIDRedirectUriVerifier.m */,
3007+
720AC2A62550D4FB00B2C7C8 /* MSIDAppExtensionUtil.m */,
30053008
);
30063009
path = mac;
30073010
sourceTree = "<group>";
@@ -3744,7 +3747,6 @@
37443747
23BDA6791FCE693800FE14BE /* MSIDKeychainUtil.m */,
37453748
96F21AEB20A4C6F2002B87C3 /* UIApplication+MSIDExtensions.h */,
37463749
96F21AEC20A4C6F2002B87C3 /* UIApplication+MSIDExtensions.m */,
3747-
96F21B0320A4FB27002B87C3 /* MSIDAppExtensionUtil.h */,
37483750
96F21B0420A4FB27002B87C3 /* MSIDAppExtensionUtil.m */,
37493751
583BFCAE24D9052E0035B901 /* MSIDRedirectUriVerifier.m */,
37503752
);
@@ -4559,6 +4561,7 @@
45594561
23B018C12356D51200207FEC /* NSDictionary+MSIDQueryItems.m */,
45604562
96CD69571FE84A0300D41938 /* MSIDJsonObject.h */,
45614563
96CD69581FE84A0300D41938 /* MSIDJsonObject.m */,
4564+
96F21B0320A4FB27002B87C3 /* MSIDAppExtensionUtil.h */,
45624565
23BDA6781FCE693800FE14BE /* MSIDKeychainUtil.h */,
45634566
B2CDB5721FE2F4DB003A4B5C /* NSOrderedSet+MSIDExtensions.h */,
45644567
B2CDB5731FE2F4DB003A4B5C /* NSOrderedSet+MSIDExtensions.m */,
@@ -6327,6 +6330,7 @@
63276330
239DF9AD20DED6F6002D428B /* MSIDConstants.m in Sources */,
63286331
23985AB52391BA1100942308 /* MSIDTokenResponseHandler.m in Sources */,
63296332
740340BB2460E5C400DFCF27 /* MSIDCurrentRequestTelemetrySerializedItem.m in Sources */,
6333+
720AC2A72550D4FB00B2C7C8 /* MSIDAppExtensionUtil.m in Sources */,
63306334
2348C313221B4EFF00498D56 /* MSIDBasicContext.m in Sources */,
63316335
600D19982095988C0004CD43 /* MSIDChallengeHandler.m in Sources */,
63326336
B26CEB042367B3B9009E6E54 /* MSIDSystemWebViewControllerFactory.m in Sources */,

IdentityCore/src/broker_operation/request/token_request/MSIDBrokerOperationBrowserTokenRequest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ NS_ASSUME_NONNULL_BEGIN
3636
@property (nonatomic, readonly) MSIDAADAuthority *authority;
3737
@property (nonatomic, readonly) NSDictionary *headers;
3838
@property (nonatomic, readonly) NSData *httpBody;
39+
@property (nonatomic, readonly) BOOL useSSOCookieFallback;
3940

4041
- (instancetype)initWithRequest:(NSURL *)requestURL
4142
headers:(NSDictionary *)headers
4243
body:(nullable NSData *)httpBody
4344
bundleIdentifier:(NSString *)bundleIdentifier
4445
requestValidator:(id<MSIDBrowserRequestValidating>)requestValidator
46+
useSSOCookieFallback:(BOOL)useSSOCookieFallback
4547
error:(NSError **)error;
4648

4749
@end

IdentityCore/src/broker_operation/request/token_request/MSIDBrokerOperationBrowserTokenRequest.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ - (instancetype)initWithRequest:(NSURL *)requestURL
3636
body:(NSData *)httpBody
3737
bundleIdentifier:(NSString *)bundleIdentifier
3838
requestValidator:(id<MSIDBrowserRequestValidating>)requestValidator
39+
useSSOCookieFallback:(BOOL)useSSOCookieFallback
3940
error:(NSError **)error
4041
{
4142
self = [super init];
@@ -65,6 +66,7 @@ - (instancetype)initWithRequest:(NSURL *)requestURL
6566
return nil;
6667
}
6768

69+
_useSSOCookieFallback = useSSOCookieFallback;
6870
_headers = headers;
6971
_httpBody = httpBody;
7072
_bundleIdentifier = bundleIdentifier;

IdentityCore/src/cache/crypto/MSIDSymmetricKey.m

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,39 @@ - (nullable NSString *)createVerifySignature:(NSData *)context
8585
return [NSString msidBase64UrlEncodedStringFromData:signedData];
8686
}
8787

88+
/**
89+
Key Derivation using Pseudorandom Functions in Counter Mode: SP 800-108
90+
Spec link: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-108.pdf
91+
Formula:
92+
93+
Fixed values:
94+
1. h - The length of the output of the PRF in bits
95+
2. r - The length of the binary representation of the counter i.
96+
Input: KI, Label, Context, and L.
97+
Process:
98+
1. n := ⎡L/h⎤.
99+
2. If n > 2^r -1, then indicate an error and stop.
100+
3. result(0):= ∅.
101+
4. For i = 1 to n, do
102+
a. K(i) := PRF (KI, [i]2 || Label || 0x00 || Context || [L]2)
103+
12
104+
SP 800-108 Recommendation for Key Derivation Using Pseudorandom Functions
105+
b. result(i) := result(i-1) || K(i).
106+
5. Return: KO := the leftmost L bits of result(n).
107+
Output: KO.
108+
109+
Implementation notes:
110+
1. PRF: we use HMAC-SHA256
111+
h: 256
112+
r: 32
113+
L: 256
114+
Label: AzureAD-SecureConversation
115+
116+
the input of HMAC-SHA256 would look like:
117+
0x00 0x00 0x00 0x01 || AzureAD-SecureConversation String in binary || 0x00 || context in binary || (256) in big-endian binary
118+
119+
*/
120+
88121
- (NSData *)computeKDFInCounterMode:(NSData *)ctx
89122
{
90123
if (ctx == nil)
@@ -112,13 +145,12 @@ - (NSData *)computeKDFInCounterMode:(NSData *)ctx
112145
return dataToReturn;
113146
}
114147

115-
116148
- (uint8_t *)kdfCounterMode:(uint8_t *)keyDerivationKey
117149
keyDerivationKeyLength:(size_t)keyDerivationKeyLength
118150
fixedInput:(uint8_t *)fixedInput
119151
fixedInputLength:(size_t)fixedInputLength
120152
{
121-
uint8_t ctr;
153+
uint32_t ctr;
122154
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
123155
uint8_t *keyDerivated;
124156
uint8_t *dataInput;
@@ -175,7 +207,7 @@ - (uint8_t *)kdfCounterMode:(uint8_t *)keyDerivationKey
175207

176208

177209
/*
178-
*Function used to shift data of 1 byte. This byte is the "ctr".
210+
*Function used to shift data by 4 byte and insert ctr in the first 4 bytes.
179211
*/
180212
- (uint8_t *)updateDataInput:(uint8_t)ctr
181213
fixedInput:(uint8_t *)fixedInput

IdentityCore/src/oauth2/token/MSIDPrimaryRefreshToken.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ - (NSUInteger)refreshInterval
208208
{
209209
if (self.expiryInterval > 0)
210210
{
211-
return self.expiryInterval / 10;
211+
return self.expiryInterval / 30;
212212
}
213213

214214
return kDefaultPRTRefreshInterval;

IdentityCore/src/requests/MSIDSilentTokenRequest.m

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,26 @@ - (void)refreshAccessToken:(MSIDBaseToken<MSIDRefreshableToken> *)refreshToken
392392

393393
[self.requestParameters.authority loadOpenIdMetadataWithContext:self.requestParameters
394394
completionBlock:^(__unused MSIDOpenIdProviderMetadata * _Nullable metadata, NSError * _Nullable error) {
395-
396-
if (error)
397-
{
398-
completionBlock(nil, error);
399-
return;
400-
}
401-
402-
[self acquireTokenWithRefreshTokenImpl:refreshToken
403-
completionBlock:completionBlock];
404-
405-
}];
395+
396+
if (error)
397+
{
398+
completionBlock(nil, error);
399+
return;
400+
}
401+
402+
// Check if token endpoint (from open id metadata) is the same cloud as the RT issuer cloud
403+
// If not the same cloud, we don't send RT to wrong cloud.
404+
if (![self.requestParameters.authority checkTokenEndpointForRTRefresh:self.requestParameters.tokenEndpoint])
405+
{
406+
NSError *interactionError = MSIDCreateError(MSIDErrorDomain, MSIDErrorInteractionRequired, @"User interaction is required (unable to use token from a different cloud).", nil, nil, nil, self.requestParameters.correlationId, nil, YES);
407+
completionBlock(nil, interactionError);
408+
return;
409+
}
410+
411+
[self acquireTokenWithRefreshTokenImpl:refreshToken
412+
completionBlock:completionBlock];
413+
414+
}];
406415
}
407416

408417
- (void)acquireTokenWithRefreshTokenImpl:(MSIDBaseToken<MSIDRefreshableToken> *)refreshToken

IdentityCore/src/telemetry/request_telemetry/MSIDLastRequestTelemetry.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder
4444
self = [super init];
4545
if (self)
4646
{
47-
self.apiId = (int)[decoder decodeFloatForKey:kApiId];
47+
self.apiId = (NSInteger)[decoder decodeFloatForKey:kApiId];
4848

4949
NSString *uuIdString = [decoder decodeObjectForKey:kCorrelationID];
5050
self.correlationId = ![NSString msidIsStringNilOrBlank:uuIdString] ? [[NSUUID UUID] initWithUUIDString:uuIdString] : nil;

IdentityCore/src/util/ios/MSIDAppExtensionUtil.h renamed to IdentityCore/src/util/MSIDAppExtensionUtil.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,28 @@
3333

3434
/// Determine whether or not the host app is an application extension based on the main bundle path
3535
+ (BOOL)isExecutingInAppExtension;
36+
37+
/// Application extension safe replacement for `openURL:`. The caller should make sure `isExecutingInAppExtension == NO` before calling this method.
38+
+ (void)sharedApplicationOpenURL:(nonnull NSURL *)url;
39+
40+
#if TARGET_OS_IPHONE
41+
// Helper method to check if the app state
42+
+ (BOOL)runningInActiveState;
43+
3644
/// Application extension safe replacement for `[UIApplication sharedApplication]`. The caller should make sure `isExecutingInAppExtension == NO` before calling this method.
3745
+ (nullable UIApplication *)sharedApplication;
38-
/// Application extension safe replacement for `[[UIApplication sharedApplication] openURL:]`. The caller should make sure `isExecutingInAppExtension == NO` before calling this method.
39-
+ (void)sharedApplicationOpenURL:(nonnull NSURL *)url;
4046

4147
/// Application extension safe replacement for `[[UIApplication sharedApplication] openURL:options:completionHandler:]`. The caller should make sure `isExecutingInAppExtension == NO` before calling this method.
4248
+ (void)sharedApplicationOpenURL:(nonnull NSURL *)url
4349
options:(nullable NSDictionary<UIApplicationOpenExternalURLOptionsKey, id> *)options
4450
completionHandler:(void (^ __nullable)(BOOL success))completionHandler;
51+
#else
52+
/// Application extension safe replacement for `[NSWorkspace sharedWorkspace]`. The caller should make sure `isExecutingInAppExtension == NO` before calling this method.
53+
+ (nullable NSWorkspace *)sharedApplication;
4554

55+
/// Application extension safe replacement for `[[NSWorkspace sharedWorkspace] openURL:configuration:completionHandler:]`. The caller should make sure `isExecutingInAppExtension == NO` before calling this method.
56+
+ (void)sharedApplicationOpenURL:(nonnull NSURL *)url
57+
configuration:(nullable NSWorkspaceOpenConfiguration *)options
58+
completionHandler:(void (^ __nullable)(BOOL success))completionHandler API_AVAILABLE(macos(10.15));
59+
#endif
4660
@end

IdentityCore/src/util/NSDictionary+MSIDExtensions.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ - (NSString *)msidWWWFormURLEncode
8888
return [NSString msidWWWFormURLEncodedStringFromDictionary:self];
8989
}
9090

91-
9291
- (NSDictionary *)msidDictionaryByRemovingFields:(NSArray *)fieldsToRemove
9392
{
9493
NSMutableDictionary *mutableDict = [self mutableCopy];

0 commit comments

Comments
 (0)