Skip to content

Commit ac0a676

Browse files
authored
Merge pull request #745 from AzureAD/release/1.5.1
1.5.1 release
2 parents f72520e + 3d65d49 commit ac0a676

File tree

94 files changed

+2118
-332
lines changed

Some content is hidden

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

94 files changed

+2118
-332
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# These owners will be the default owners for everything in the repo.
22
# Unless a later match takes precedence, these users will be requested
33
# for review whenever someone opens a pull request.
4-
* @AzureAD/AppleIdentity
4+
* @AzureAD/AppleIdentityTeam
55
# IdentityCore/src/util @AzureAD/AppleCppIdentity
66
# IdentityCore/src/cache @AzureAD/AppleCppIdentity
77
# For more details about inheritance patterns, or to assign different

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 112 additions & 0 deletions
Large diffs are not rendered by default.

IdentityCore/src/MSIDExternalAADCacheSeeder.m

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,31 @@ - (void)seedExternalCacheWithIdToken:(MSIDIdToken *)idToken
215215
configuration:configuration];
216216
refreshToken.idToken = idToken.rawIdToken;
217217

218-
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"Saving refresh token in external cache.");
218+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"Checking refresh token existence in external cache.");
219219

220220
NSError *error;
221+
MSIDRefreshToken *existingRefreshToken = [self.externalLegacyAccessor getRefreshTokenWithAccount:refreshToken.accountIdentifier
222+
familyId:refreshToken.familyId
223+
configuration:configuration
224+
context:context
225+
error:&error];
226+
227+
if (error)
228+
{
229+
MSID_LOG_WITH_CTX_PII(MSIDLogLevelError, context, @"Failed to read refresh token from external cache, error: %@", MSID_PII_LOG_MASKABLE(error));
230+
completionBlock(NO);
231+
return;
232+
}
233+
234+
if (existingRefreshToken)
235+
{
236+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"Found existing refresh token in external cache. Returning early.");
237+
completionBlock(YES);
238+
return;
239+
}
240+
241+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"Saving refresh token in external cache.");
242+
221243
BOOL result = [self.externalLegacyAccessor saveRefreshToken:refreshToken
222244
configuration:configuration
223245
context:context
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
24+
#import <Foundation/Foundation.h>
25+
26+
NS_ASSUME_NONNULL_BEGIN
27+
28+
@protocol MSIDTelemetryStringSerializable <NSObject>
29+
30+
- (NSString *)telemetryString;
31+
32+
@end
33+
34+
NS_ASSUME_NONNULL_END

IdentityCore/src/broker_operation/request/account_request/MSIDBrokerOperationSignoutFromDeviceRequest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
3838
@property (readwrite) NSString *redirectUri;
3939
@property (nonatomic) MSIDProviderType providerType;
4040
@property (nonatomic) BOOL signoutFromBrowser;
41+
@property (nonatomic) BOOL clearSSOExtensionCookies;
4142

4243
@end
4344

IdentityCore/src/broker_operation/request/account_request/MSIDBrokerOperationSignoutFromDeviceRequest.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#import "MSIDJsonSerializableTypes.h"
3333

3434
NSString *const MSID_SIGNOUT_FROM_BROWSER_KEY = @"signout_from_browser";
35+
NSString *const MSID_CLEAR_SSO_EXT_COOKIES_KEY = @"clear_sso_extension_cookies";
3536

3637
@implementation MSIDBrokerOperationSignoutFromDeviceRequest
3738

@@ -65,6 +66,7 @@ - (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError **)er
6566
_redirectUri = [json msidStringObjectForKey:MSID_REDIRECT_URI_JSON_KEY];
6667
_providerType = MSIDProviderTypeFromString([json msidStringObjectForKey:MSID_PROVIDER_TYPE_JSON_KEY]);
6768
_signoutFromBrowser = [json msidBoolObjectForKey:MSID_SIGNOUT_FROM_BROWSER_KEY];
69+
_clearSSOExtensionCookies = [json msidBoolObjectForKey:MSID_CLEAR_SSO_EXT_COOKIES_KEY];
6870
}
6971

7072
return self;
@@ -93,6 +95,7 @@ - (NSDictionary *)jsonDictionary
9395

9496
json[MSID_PROVIDER_TYPE_JSON_KEY] = MSIDProviderTypeToString(self.providerType);
9597
json[MSID_SIGNOUT_FROM_BROWSER_KEY] = @(_signoutFromBrowser);
98+
json[MSID_CLEAR_SSO_EXT_COOKIES_KEY] = @(_clearSSOExtensionCookies);
9699

97100
return json;
98101
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#import <Foundation/Foundation.h>
2525
#import "MSIDBaseBrokerOperationRequest.h"
26+
#import "MSIDBrowserRequestValidating.h"
2627

2728
NS_ASSUME_NONNULL_BEGIN
2829

@@ -35,10 +36,13 @@ NS_ASSUME_NONNULL_BEGIN
3536
@property (nonatomic, readonly) MSIDAADAuthority *authority;
3637
@property (nonatomic, readonly) NSDictionary *headers;
3738
@property (nonatomic, readonly) NSUUID *correlationId;
39+
@property (nonatomic, readonly) NSData *httpBody;
3840

3941
- (instancetype)initWithRequest:(NSURL *)requestURL
4042
headers:(NSDictionary *)headers
43+
body:(nullable NSData *)httpBody
4144
bundleIdentifier:(NSString *)bundleIdentifier
45+
requestValidator:(id<MSIDBrowserRequestValidating>)requestValidator
4246
error:(NSError **)error;
4347

4448
@end

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

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ @implementation MSIDBrokerOperationBrowserTokenRequest
3333

3434
- (instancetype)initWithRequest:(NSURL *)requestURL
3535
headers:(NSDictionary *)headers
36+
body:(NSData *)httpBody
3637
bundleIdentifier:(NSString *)bundleIdentifier
38+
requestValidator:(id<MSIDBrowserRequestValidating>)requestValidator
3739
error:(NSError **)error
3840
{
3941
self = [super init];
@@ -52,7 +54,7 @@ - (instancetype)initWithRequest:(NSURL *)requestURL
5254

5355
_requestURL = requestURL;
5456

55-
if (![self shouldHandleURL:_requestURL])
57+
if (![requestValidator shouldHandleURL:_requestURL])
5658
{
5759
if (error)
5860
{
@@ -64,6 +66,7 @@ - (instancetype)initWithRequest:(NSURL *)requestURL
6466
}
6567

6668
_headers = headers;
69+
_httpBody = httpBody;
6770
_bundleIdentifier = bundleIdentifier;
6871

6972
MSIDAADAuthority *authority = [[MSIDAADAuthority alloc] initWithURL:_requestURL rawTenant:nil context:nil error:error];
@@ -85,27 +88,6 @@ - (instancetype)initWithRequest:(NSURL *)requestURL
8588
return self;
8689
}
8790

88-
- (BOOL)shouldHandleURL:(NSURL *)url
89-
{
90-
if (![url msidContainsCaseInsensitivePath:@"oauth2"])
91-
{
92-
return NO;
93-
}
94-
95-
if ([url msidContainsCaseInsensitivePath:@"/oauth2/authorize"])
96-
{
97-
return YES;
98-
}
99-
100-
if ([url msidContainsCaseInsensitivePath:@"/oauth2/v2.0/authorize"])
101-
{
102-
return YES;
103-
}
104-
105-
BOOL isLogoutRequest = [url msidContainsCaseInsensitivePath:@"logout"] && [url msidContainsPathComponent:@"logout"];
106-
return isLogoutRequest;
107-
}
108-
10991
#pragma mark - MSIDBaseBrokerOperationRequest
11092

11193
+ (NSString *)operation
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
24+
#import <Foundation/Foundation.h>
25+
26+
NS_ASSUME_NONNULL_BEGIN
27+
28+
@protocol MSIDBrowserRequestValidating <NSObject>
29+
30+
- (BOOL)shouldHandleURL:(NSURL *)url;
31+
32+
@end
33+
34+
NS_ASSUME_NONNULL_END

IdentityCore/src/cache/metadata/MSIDAccountMetadataCacheAccessor.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ - (MSIDAccountMetadataState)signInStateForHomeAccountId:(NSString *)homeAccountI
147147
}
148148

149149
NSError *localError;
150-
MSIDAccountMetadataCacheItem *cacheItem = [self retrieveAccountMetadataCacheItemForClientId:clientId skipCache:self.skipMemoryCacheForAccountMetadata context:context error:&localError];
150+
MSIDAccountMetadataCacheItem *cacheItem = [self retrieveAccountMetadataCacheItemForClientId:clientId skipCache:YES context:context error:&localError];
151151
if (localError)
152152
{
153153
if (error) *error = localError;
@@ -173,7 +173,7 @@ - (BOOL)updateSignInStateForHomeAccountId:(NSString *)homeAccountId
173173
}
174174

175175
NSError *localError;
176-
MSIDAccountMetadataCacheItem *cacheItem = [self retrieveAccountMetadataCacheItemForClientId:clientId skipCache:self.skipMemoryCacheForAccountMetadata context:context error:&localError];
176+
MSIDAccountMetadataCacheItem *cacheItem = [self retrieveAccountMetadataCacheItemForClientId:clientId skipCache:YES context:context error:&localError];
177177
if (localError)
178178
{
179179
if (error) *error = localError;

0 commit comments

Comments
 (0)