-
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
Move authority migration to common core #130
Changes from all commits
334d9b1
66e060f
9efe74a
6103efe
718d5f5
88584ce
8cd8321
28deb6d
3fa5855
10c0e5a
8d1b88c
8964c86
564a53a
c4920d6
1b9bdb6
45193a7
eaca231
01853dc
e61f1f3
6dfb0cb
1f6ecc1
95e35eb
2904d21
91e015b
4e8216c
7fde238
11ec446
692263b
0310089
36e92d7
606e3ec
7e6e4ae
12eb8d3
d473f37
1622598
fa65a88
883fc44
f44b550
55fc7fc
adf32e8
24264e9
3c5200d
3e01653
3022965
c087868
4ddf021
582c07b
4b57b29
851ac1b
eb4b053
9e48c84
c401073
55a04ff
17efef8
b7a13c1
fd756c3
f415923
04e8c61
8c6a2c6
c5d365a
1c16743
ed78126
ae4c191
3a28811
f5c9d91
86e859e
bbc6a7c
917c0c3
37a1276
69233e9
0b676f1
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, | ||
MSIDADFSTypeCloud | ||
}; |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// 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 "MSIDAADEndpointProvider.h" | ||
#import "MSIDAADNetworkConfiguration.h" | ||
|
||
@implementation MSIDAADEndpointProvider | ||
|
||
#pragma mark - MSIDEndpointProviderProtocol | ||
|
||
- (NSURL *)oauth2AuthorizeEndpointWithUrl:(NSURL *)baseUrl | ||
{ | ||
__auto_type apiVersion = [self aadApiVersionWithDelimiter]; | ||
|
||
return [baseUrl URLByAppendingPathComponent:[NSString stringWithFormat:@"/oauth2/%@authorize", apiVersion]]; | ||
} | ||
|
||
- (NSURL *)oauth2TokenEndpointWithUrl:(NSURL *)baseUrl | ||
{ | ||
__auto_type apiVersion = [self aadApiVersionWithDelimiter]; | ||
|
||
return [baseUrl URLByAppendingPathComponent:[NSString stringWithFormat:@"/oauth2/%@token", apiVersion]]; | ||
} | ||
|
||
- (NSURL *)drsDiscoveryEndpointWithDomain:(NSString *)domain adfsType:(MSIDADFSType)type | ||
{ | ||
if (type == MSIDADFSTypeOnPrems) | ||
{ | ||
return [NSURL URLWithString: | ||
[NSString stringWithFormat:@"https://enterpriseregistration.%@/enrollmentserver/contract", domain.lowercaseString]]; | ||
} | ||
else if (type == MSIDADFSTypeCloud) | ||
{ | ||
return [NSURL URLWithString: | ||
[NSString stringWithFormat:@"https://enterpriseregistration.windows.net/%@/enrollmentserver/contract", domain.lowercaseString]]; | ||
} | ||
|
||
return nil; | ||
} | ||
|
||
- (NSURL *)webFingerDiscoveryEndpointWithIssuer:(NSURL *)issuer | ||
{ | ||
return [NSURL URLWithString:[NSString stringWithFormat:@"https://%@/.well-known/webfinger", issuer.host]]; | ||
} | ||
|
||
- (NSURL *)openIdConfigurationEndpointWithUrl:(NSURL *)baseUrl | ||
{ | ||
if (!baseUrl) return nil; | ||
|
||
__auto_type apiVersion = [self aadApiVersionWithDelimiter]; | ||
__auto_type path = [NSString stringWithFormat:@"%@%@", apiVersion, MSID_OPENID_CONFIGURATION_SUFFIX]; | ||
|
||
return [baseUrl URLByAppendingPathComponent:path]; | ||
} | ||
|
||
- (NSURL *)aadAuthorityDiscoveryEndpointWithHost:(NSString *)host | ||
{ | ||
__auto_type trustedAuthority = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"https://%@", host]]; | ||
return [trustedAuthority URLByAppendingPathComponent:MSID_OAUTH2_INSTANCE_DISCOVERY_SUFFIX]; | ||
} | ||
|
||
#pragma mark - Private | ||
|
||
- (NSString *)aadApiVersionWithDelimiter | ||
{ | ||
__auto_type apiVersion = MSIDAADNetworkConfiguration.defaultConfiguration.aadApiVersion ?: @""; | ||
__auto_type delimiter = MSIDAADNetworkConfiguration.defaultConfiguration.aadApiVersion ? @"/" : @""; | ||
|
||
return [NSString stringWithFormat:@"%@%@", apiVersion, delimiter]; | ||
} | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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 "MSIDADFSType.h" | ||
|
||
@protocol MSIDAADEndpointProviding <NSObject> | ||
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: endpoint providing should apply also to basic Oauth2 flow, not only to AAD (e.g. we should be able to find an authorize endpoint or openid config for Google). We can take this as a separate issue though. 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. Added comment about it in #211 |
||
|
||
- (NSURL *)oauth2AuthorizeEndpointWithUrl:(NSURL *)baseUrl; | ||
|
||
- (NSURL *)oauth2TokenEndpointWithUrl:(NSURL *)baseUrl; | ||
|
||
- (NSURL *)drsDiscoveryEndpointWithDomain:(NSString *)domain adfsType:(MSIDADFSType)type; | ||
|
||
- (NSURL *)webFingerDiscoveryEndpointWithIssuer:(NSURL *)issuer; | ||
|
||
- (NSURL *)openIdConfigurationEndpointWithUrl:(NSURL *)baseUrl; | ||
|
||
- (NSURL *)aadAuthorityDiscoveryEndpointWithHost:(NSString *)host; | ||
|
||
|
||
@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.
I think drs discovery endpoint doesn't belong here, because it's ADFS and not AAD specific.
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.
created issue #211