-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split authority #151
Split authority #151
Changes from 55 commits
e84b227
263cf6f
e4e2bc3
94b7545
d4b1ded
346dd15
14a75fe
3f3f925
77ee6d3
12739ce
423d24f
7d57ca4
5ade21d
b6ef418
8f245a9
374a7b9
33a5041
ee537b0
10a8ada
7ac3f98
fe02792
d5457e3
d06fd38
4f7642e
eea6019
fa1d573
50aa997
8d320a5
18255d8
e032078
5fd5f21
e45ed5d
ee20e42
b7b7c2a
8063c50
ca446c4
0812464
3d1d0a6
d2a1d30
1991882
9ccc679
666c64b
1434eb0
c0b00df
11d74cc
2785096
ff5e718
26ebba1
94a7622
8985b65
5bbda28
c9e0945
5f33aa3
1308a1b
c517b89
9b30681
b14ff46
bbcb8c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "MSIDAADEndpointProviding.h" | ||
|
||
@interface MSIDAADNetworkConfiguration : NSObject | ||
|
||
@property (class, nullable) MSIDAADNetworkConfiguration *defaultConfiguration; | ||
|
||
@property (nonatomic, nonnull) id<MSIDAADEndpointProviding> endpointProvider; | ||
|
||
@property (nonatomic, nullable) NSString *aadApiVersion; | ||
|
||
@property (nonatomic, nullable) NSString *aadAuthorityDiscoveryApiVersion; | ||
|
||
@property (nonatomic, nullable) NSString *drsDiscoveryApiVersion; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import "MSIDAADNetworkConfiguration.h" | ||
#import "MSIDAADEndpointProvider.h" | ||
|
||
static MSIDAADNetworkConfiguration *s_defaultConfiguration; | ||
|
||
@implementation MSIDAADNetworkConfiguration | ||
|
||
+ (void)initialize | ||
{ | ||
if (self == [MSIDAADNetworkConfiguration self]) | ||
{ | ||
s_defaultConfiguration = [MSIDAADNetworkConfiguration new]; | ||
} | ||
} | ||
|
||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
if (self) | ||
{ | ||
_endpointProvider = [MSIDAADEndpointProvider new]; | ||
_aadAuthorityDiscoveryApiVersion = @"1.1"; | ||
_drsDiscoveryApiVersion = @"1.0"; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
+ (MSIDAADNetworkConfiguration *)defaultConfiguration | ||
{ | ||
return s_defaultConfiguration; | ||
} | ||
|
||
+ (void)setDefaultConfiguration:(MSIDAADNetworkConfiguration *)defaultConfiguration | ||
{ | ||
s_defaultConfiguration = defaultConfiguration; | ||
} | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
typedef NS_ENUM(NSInteger, MSIDADFSType) | ||
{ | ||
MSIDADFSTypeOnPrems, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: OnPrems -> OnPrem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
MSIDADFSTypeCloud | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rename MSIDADFSTypeCloud to something more appropriate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import "MSIDCache.h" | ||
|
||
@interface MSIDCache () | ||
|
||
@property (nonatomic) NSMutableDictionary *container; | ||
@property (nonatomic) dispatch_queue_t synchronizationQueue; | ||
|
||
@end | ||
|
||
@implementation MSIDCache | ||
|
||
- (instancetype)init | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
NSString *queueName = [NSString stringWithFormat:@"com.microsoft.msidcache-%@", [NSUUID UUID].UUIDString]; | ||
_synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); | ||
_container = [NSMutableDictionary new]; | ||
|
||
return self; | ||
} | ||
|
||
- (id)objectForKey:(id)key | ||
{ | ||
__block id object; | ||
dispatch_sync(self.synchronizationQueue, ^{ | ||
object = [self.container objectForKey:key]; | ||
}); | ||
|
||
return object; | ||
} | ||
|
||
- (void)setObject:(id)obj forKey:(id)key | ||
{ | ||
dispatch_barrier_sync(self.synchronizationQueue, ^{ | ||
[self.container setObject:obj forKey:key]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you fixed this to use subscript in another PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it was fixed in another PR. |
||
}); | ||
} | ||
|
||
- (void)removeObjectForKey:(id)key | ||
{ | ||
dispatch_barrier_sync(self.synchronizationQueue, ^{ | ||
[self.container removeObjectForKey:key]; | ||
}); | ||
} | ||
|
||
- (void)removeAllObjects | ||
{ | ||
dispatch_barrier_sync(self.synchronizationQueue, ^{ | ||
[self.container removeAllObjects]; | ||
}); | ||
} | ||
|
||
- (NSUInteger)count | ||
{ | ||
__block NSUInteger count = 0; | ||
dispatch_sync(self.synchronizationQueue, ^{ | ||
count = self.container.allKeys.count; | ||
}); | ||
|
||
return count; | ||
} | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,6 @@ extern NSString *const MSID_OAUTH2_AUTHORIZATION; | |
extern NSString *const MSID_OAUTH2_AUTHORIZATION_CODE; | ||
extern NSString *const MSID_OAUTH2_AUTHORIZATION_URI; | ||
extern NSString *const MSID_OAUTH2_AUTHORITY; | ||
extern NSString *const MSID_OAUTH2_AUTHORIZE_SUFFIX; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. those constants are still used in ADAL. Please revert removal... |
||
extern NSString *const MSID_OAUTH2_V2_AUTHORIZE_SUFFIX; | ||
extern NSString *const MSID_OAUTH2_BEARER; | ||
extern NSString *const MSID_OAUTH2_CLIENT_ID; | ||
extern NSString *const MSID_OAUTH2_CLAIMS; | ||
|
@@ -45,7 +43,6 @@ extern NSString *const MSID_OAUTH2_SCOPE; | |
extern NSString *const MSID_OAUTH2_STATE; | ||
extern NSString *const MSID_OAUTH2_SUB_ERROR; | ||
extern NSString *const MSID_OAUTH2_TOKEN; | ||
extern NSString *const MSID_OAUTH2_TOKEN_SUFFIX; | ||
extern NSString *const MSID_OAUTH2_INSTANCE_DISCOVERY_SUFFIX; | ||
extern NSString *const MSID_OAUTH2_TOKEN_TYPE; | ||
extern NSString *const MSID_OAUTH2_LOGIN_HINT; | ||
|
@@ -117,3 +114,5 @@ extern NSString *const MSID_REFRESH_TOKEN_CACHE_TYPE; | |
extern NSString *const MSID_LEGACY_TOKEN_CACHE_TYPE; | ||
extern NSString *const MSID_ID_TOKEN_CACHE_TYPE; | ||
extern NSString *const MSID_GENERAL_TOKEN_CACHE_TYPE; | ||
|
||
extern NSString *const MSID_OPENID_CONFIGURATION_SUFFIX; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
#import "MSIDIdTokenClaims.h" | ||
#import "MSIDAccountIdentifier.h" | ||
#import "MSIDTelemetry+Cache.h" | ||
#import "MSIDAuthorityFactory.h" | ||
|
||
@interface MSIDLegacyTokenCacheAccessor() | ||
{ | ||
|
@@ -259,7 +260,10 @@ - (BOOL)clearWithContext:(id<MSIDRequestContext>)context | |
{ | ||
MSIDAccount *account = [MSIDAccount new]; | ||
account.homeAccountId = refreshToken.homeAccountId; | ||
account.authority = [MSIDAuthority cacheUrlForAuthority:refreshToken.authority tenantId:refreshToken.realm]; | ||
|
||
__auto_type authorityFactory = [MSIDAuthorityFactory new]; | ||
__auto_type authority = [authorityFactory authorityFromUrl:refreshToken.authority rawTenant:refreshToken.realm context:nil error:nil]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this do authority aliasing? |
||
account.authority = authority; | ||
account.accountType = MSIDAccountTypeMSSTS; | ||
account.username = refreshToken.legacyUserId; | ||
[resultAccounts addObject:account]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "MSIDAADEndpointProviding.h" | ||
|
||
@interface MSIDAADEndpointProvider : NSObject <MSIDAADEndpointProviding> | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do we use DRS for AAD authority validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't use it for AAD, it is for ADFS authority validation.