Skip to content

Commit

Permalink
Merge from base branch
Browse files Browse the repository at this point in the history
  • Loading branch information
oldalton committed Oct 26, 2018
2 parents e1b8305 + f280a43 commit a28ce2e
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 91 deletions.
2 changes: 1 addition & 1 deletion MSAL/IdentityCore
Submodule IdentityCore updated 27 files
+60 −0 IdentityCore/IdentityCore.xcodeproj/project.pbxproj
+2 −0 IdentityCore/src/MSIDConstants.h
+2 −0 IdentityCore/src/MSIDConstants.m
+1 −0 IdentityCore/src/MSIDRequestContext.h
+15 −15 IdentityCore/src/cache/accessor/MSIDLegacyTokenCacheAccessor.m
+5 −0 IdentityCore/src/network/request_configurator/MSIDAADRequestConfigurator.m
+4 −0 IdentityCore/src/oauth2/aad_v2/MSIDAADV2Oauth2Factory.h
+13 −17 IdentityCore/src/oauth2/aad_v2/MSIDAADV2Oauth2Factory.m
+39 −0 IdentityCore/src/oauth2/b2c/MSIDB2CIdTokenClaims.h
+65 −0 IdentityCore/src/oauth2/b2c/MSIDB2CIdTokenClaims.m
+36 −0 IdentityCore/src/oauth2/b2c/MSIDB2COauth2Factory.h
+133 −0 IdentityCore/src/oauth2/b2c/MSIDB2COauth2Factory.m
+36 −0 IdentityCore/src/oauth2/b2c/MSIDB2CTokenResponse.h
+32 −0 IdentityCore/src/oauth2/b2c/MSIDB2CTokenResponse.m
+46 −0 IdentityCore/src/util/MSIDClientCapabilitiesUtil.h
+96 −0 IdentityCore/src/util/MSIDClientCapabilitiesUtil.m
+1 −0 IdentityCore/src/util/NSURL+MSIDExtensions.h
+45 −0 IdentityCore/src/util/NSURL+MSIDExtensions.m
+2 −2 IdentityCore/tests/MSIDAADV2Oauth2FactoryTests.m
+277 −0 IdentityCore/tests/MSIDB2COauth2FactoryTests.m
+137 −0 IdentityCore/tests/MSIDClientCapabilitiesTests.m
+64 −0 IdentityCore/tests/MSIDURLExtensionsTests.m
+20 −18 IdentityCore/tests/integration/MSIDCacheSchemaValidationTests.m
+1 −0 IdentityCore/tests/integration/ios/MSIDWipeDataTelemetryTests.m
+1 −0 IdentityCore/tests/util/MSIDTestContext.h
+2 −2 IdentityCore/tests/util/MSIDTestIdTokenUtil.m
+2 −0 IdentityCore/tests/util/network/MSIDTestURLResponse.m
18 changes: 18 additions & 0 deletions MSAL/MSAL.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
B221CEEC20C0AF0B002F5E94 /* MSALAccountId+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = B221CEEA20C0AF0B002F5E94 /* MSALAccountId+Internal.h */; };
B2341A2A21507CA1008E93FC /* AuthenticationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963C89A6214BA1760051AFEE /* AuthenticationServices.framework */; };
B2341A2B21507CA7008E93FC /* AuthenticationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963C89A6214BA1760051AFEE /* AuthenticationServices.framework */; };
B256121B217EA44900999876 /* MSALOauth2FactoryProducerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B256121A217EA44900999876 /* MSALOauth2FactoryProducerTests.m */; };
B256121C217EA44900999876 /* MSALOauth2FactoryProducerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B256121A217EA44900999876 /* MSALOauth2FactoryProducerTests.m */; };
B25F1BBB1EC3DB3200474D1B /* MSIDTokenCacheItem+Automation.m in Sources */ = {isa = PBXBuildFile; fileRef = B25F1BBA1EC3DB3200474D1B /* MSIDTokenCacheItem+Automation.m */; };
B25F1BC11EC3DD3200474D1B /* MSALUser+Automation.m in Sources */ = {isa = PBXBuildFile; fileRef = B25F1BC01EC3DD3200474D1B /* MSALUser+Automation.m */; };
B25F1BC41EC3E44500474D1B /* MSALResult+Automation.m in Sources */ = {isa = PBXBuildFile; fileRef = B25F1BC31EC3E44500474D1B /* MSALResult+Automation.m */; };
Expand All @@ -115,6 +117,10 @@
B2734C1C21253AD300DAB1CD /* MSALMultiAppCacheCoexistenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2734C1B21253AD300DAB1CD /* MSALMultiAppCacheCoexistenceTests.m */; };
B2734C1E21253B1B00DAB1CD /* MSALDotNetCacheCoexistenceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2734C1D21253B1B00DAB1CD /* MSALDotNetCacheCoexistenceTests.m */; };
B277241E1EAE97D700375C53 /* MSALStressTestHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = B277241D1EAE97D700375C53 /* MSALStressTestHelper.m */; };
B28BDA8E217E9EAB003E5670 /* MSALOauth2FactoryProducer.h in Headers */ = {isa = PBXBuildFile; fileRef = B28BDA8C217E9EAB003E5670 /* MSALOauth2FactoryProducer.h */; };
B28BDA8F217E9EAB003E5670 /* MSALOauth2FactoryProducer.h in Headers */ = {isa = PBXBuildFile; fileRef = B28BDA8C217E9EAB003E5670 /* MSALOauth2FactoryProducer.h */; };
B28BDA90217E9EAB003E5670 /* MSALOauth2FactoryProducer.m in Sources */ = {isa = PBXBuildFile; fileRef = B28BDA8D217E9EAB003E5670 /* MSALOauth2FactoryProducer.m */; };
B28BDA91217E9EAB003E5670 /* MSALOauth2FactoryProducer.m in Sources */ = {isa = PBXBuildFile; fileRef = B28BDA8D217E9EAB003E5670 /* MSALOauth2FactoryProducer.m */; };
B29E2AC221238DCD00B170ED /* libIdentityCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A206231FC50A4D00755A51 /* libIdentityCore.a */; };
B29E2AC321238DFC00B170ED /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96902DEC20E1574F00200E6F /* WebKit.framework */; };
B29E2AC521238E0000B170ED /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B29E2AC421238E0000B170ED /* SafariServices.framework */; };
Expand Down Expand Up @@ -556,6 +562,7 @@
B221CED920C0AC60002F5E94 /* MSALAccountId.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSALAccountId.h; sourceTree = "<group>"; };
B221CEDA20C0AC60002F5E94 /* MSALAccountId.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSALAccountId.m; sourceTree = "<group>"; };
B221CEEA20C0AF0B002F5E94 /* MSALAccountId+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MSALAccountId+Internal.h"; sourceTree = "<group>"; };
B256121A217EA44900999876 /* MSALOauth2FactoryProducerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSALOauth2FactoryProducerTests.m; sourceTree = "<group>"; };
B25F1BB21EC257F900474D1B /* MSALB2CPolicyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSALB2CPolicyTests.m; sourceTree = "<group>"; };
B25F1BB91EC3DB3200474D1B /* MSIDTokenCacheItem+Automation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MSIDTokenCacheItem+Automation.h"; sourceTree = "<group>"; };
B25F1BBA1EC3DB3200474D1B /* MSIDTokenCacheItem+Automation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MSIDTokenCacheItem+Automation.m"; sourceTree = "<group>"; };
Expand All @@ -571,6 +578,8 @@
B2734C1D21253B1B00DAB1CD /* MSALDotNetCacheCoexistenceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSALDotNetCacheCoexistenceTests.m; sourceTree = "<group>"; };
B277241C1EAE97D700375C53 /* MSALStressTestHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSALStressTestHelper.h; sourceTree = "<group>"; };
B277241D1EAE97D700375C53 /* MSALStressTestHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSALStressTestHelper.m; sourceTree = "<group>"; };
B28BDA8C217E9EAB003E5670 /* MSALOauth2FactoryProducer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSALOauth2FactoryProducer.h; sourceTree = "<group>"; };
B28BDA8D217E9EAB003E5670 /* MSALOauth2FactoryProducer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSALOauth2FactoryProducer.m; sourceTree = "<group>"; };
B29E2AC421238E0000B170ED /* SafariServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SafariServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework; sourceTree = DEVELOPER_DIR; };
B29E2AC821238F2200B170ED /* MSALNonUnifiedADALCoexistenceCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSALNonUnifiedADALCoexistenceCacheTests.m; sourceTree = "<group>"; };
B29E2ACE21238F5200B170ED /* MultiAppiOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MultiAppiOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -861,6 +870,8 @@
23A68A7F20F538DE0071E435 /* MSALADFSAuthority.m */,
23A68A8B20F57A440071E435 /* MSALAuthorityFactory.h */,
23A68A8C20F57A440071E435 /* MSALAuthorityFactory.m */,
B28BDA8C217E9EAB003E5670 /* MSALOauth2FactoryProducer.h */,
B28BDA8D217E9EAB003E5670 /* MSALOauth2FactoryProducer.m */,
);
path = instance;
sourceTree = "<group>";
Expand Down Expand Up @@ -1260,6 +1271,7 @@
B25F1BB21EC257F900474D1B /* MSALB2CPolicyTests.m */,
04D32CCF1FD8AFF3000B123E /* MSALErrorConverterTests.m */,
B210E3E21FC23D4700E7A325 /* MSALErrorTests.m */,
B256121A217EA44900999876 /* MSALOauth2FactoryProducerTests.m */,
);
path = unit;
sourceTree = "<group>";
Expand Down Expand Up @@ -1467,6 +1479,7 @@
23F32F071FF4787600B2905E /* MSIDTestURLResponse+MSAL.h in Headers */,
D65A6FB21E3FF41D00C69FBA /* MSALError.h in Headers */,
9682624C20E304F30080694D /* MSALWebviewType.h in Headers */,
B28BDA8E217E9EAB003E5670 /* MSALOauth2FactoryProducer.h in Headers */,
D65A6FB41E3FF41D00C69FBA /* MSALPublicClientApplication.h in Headers */,
B2A3C29621460D290082525C /* MSALAuthority.h in Headers */,
B21E07B1210E542C007E3A3C /* MSALRedirectUriVerifier.h in Headers */,
Expand Down Expand Up @@ -1496,6 +1509,7 @@
B2B5F08C1FCA61EB00F6AFAD /* MSALTelemetryDefaultEvent.h in Headers */,
D673F0791E4A633B0018BA91 /* MSALError_Internal.h in Headers */,
B21E07B2210E542C007E3A3C /* MSALRedirectUriVerifier.h in Headers */,
B28BDA8F217E9EAB003E5670 /* MSALOauth2FactoryProducer.h in Headers */,
94E876DF1E495F2700FB96ED /* MSALUIBehavior.h in Headers */,
D65A6FA91E3FF3D900C69FBA /* MSALError.h in Headers */,
96D9A5451E4AB1DC00674A85 /* MSALTelemetry.h in Headers */,
Expand Down Expand Up @@ -2107,6 +2121,7 @@
D61BD2AF1EBD09F90007E484 /* MSALLogger.m in Sources */,
D61BD2BF1EBD0A010007E484 /* MSALDefaultDispatcher.m in Sources */,
D61BD2B81EBD0A010007E484 /* MSALTelemetryAPIEvent.m in Sources */,
B28BDA90217E9EAB003E5670 /* MSALOauth2FactoryProducer.m in Sources */,
D61BD2B01EBD09F90007E484 /* MSALPublicClientApplication.m in Sources */,
D61BD2AD1EBD09F90007E484 /* MSALError.m in Sources */,
963377C1211E14C600943EE0 /* MSALWebviewType.m in Sources */,
Expand Down Expand Up @@ -2141,6 +2156,7 @@
D673F08F1E4CE6D70018BA91 /* MSALError.m in Sources */,
23A68A8320F538DE0071E435 /* MSALADFSAuthority.m in Sources */,
23A68A7720F5386A0071E435 /* MSALAADAuthority.m in Sources */,
B28BDA91217E9EAB003E5670 /* MSALOauth2FactoryProducer.m in Sources */,
D673F0951E4CE6DB0018BA91 /* MSALRequestParameters.m in Sources */,
D673F0981E4CE6DB0018BA91 /* MSALInteractiveRequest.m in Sources */,
D673F0911E4CE6D70018BA91 /* MSALLogger.m in Sources */,
Expand Down Expand Up @@ -2170,6 +2186,7 @@
D61F5BC01E5913BE00912CB8 /* SFSafariViewController+TestOverrides.m in Sources */,
D69ADB351E516F9B00952049 /* MSALTestBundle.m in Sources */,
D69ADB3F1E516F9B00952049 /* MSALTestURLSessionDataTask.m in Sources */,
B256121B217EA44900999876 /* MSALOauth2FactoryProducerTests.m in Sources */,
D62746D91E9B5F1E00EFCE99 /* MSALUserTests.m in Sources */,
D69ADB3D1E516F9B00952049 /* MSIDTestURLSession+MSAL.m in Sources */,
2364C74B1FB3E5CB00835428 /* XCTestCase+HelperMethods.m in Sources */,
Expand Down Expand Up @@ -2201,6 +2218,7 @@
B21E07C3210E5C3C007E3A3C /* MSALRedirectUriVerifierTests.m in Sources */,
D69ADB401E516F9B00952049 /* MSALTestURLSessionDataTask.m in Sources */,
D62746DA1E9B5F1E00EFCE99 /* MSALUserTests.m in Sources */,
B256121C217EA44900999876 /* MSALOauth2FactoryProducerTests.m in Sources */,
D69ADB3C1E516F9B00952049 /* MSALTestSwizzle.m in Sources */,
D69ADB381E516F9B00952049 /* MSALTestCase.m in Sources */,
04D32CD11FD8AFF3000B123E /* MSALErrorConverterTests.m in Sources */,
Expand Down
24 changes: 16 additions & 8 deletions MSAL/src/MSALPublicClientApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#import "MSIDAADAuthority.h"
#import "MSIDAuthorityFactory.h"
#import "MSALAADAuthority.h"
#import "MSALOauth2FactoryProducer.h"

static NSString *const s_defaultAuthorityUrlString = @"https://login.microsoftonline.com/common";

Expand All @@ -71,6 +72,7 @@ @interface MSALPublicClientApplication()
{
WKWebView *_customWebview;
NSString *_defaultKeychainGroup;
MSIDOauth2Factory *_oauth2Factory;
}

@property (nonatomic) MSIDDefaultTokenCacheAccessor *tokenCache;
Expand Down Expand Up @@ -205,6 +207,14 @@ - (id)initWithClientId:(NSString *)clientId
_authority = [[MSALAADAuthority alloc] initWithURL:authorityURL context:nil error:error];
}

_oauth2Factory = [MSALOauth2FactoryProducer msidOauth2FactoryForAuthority:_authority.url context:nil error:error];

if (!_oauth2Factory)
{
MSID_LOG_ERROR(nil, @"Couldn't create Oauth2 factory");
return nil;
}

BOOL redirectUriValid = [self verifyRedirectUri:redirectUri clientId:clientId error:error];

if (!redirectUriValid) return nil;
Expand All @@ -220,11 +230,9 @@ - (id)initWithClientId:(NSString *)clientId
}

dataSource = [[MSIDKeychainTokenCache alloc] initWithGroup:_keychainGroup];

MSIDOauth2Factory *factory = [MSIDAADV2Oauth2Factory new];

MSIDLegacyTokenCacheAccessor *legacyAccessor = [[MSIDLegacyTokenCacheAccessor alloc] initWithDataSource:dataSource otherCacheAccessors:nil factory:factory];
MSIDDefaultTokenCacheAccessor *defaultAccessor = [[MSIDDefaultTokenCacheAccessor alloc] initWithDataSource:dataSource otherCacheAccessors:@[legacyAccessor] factory:factory];

MSIDLegacyTokenCacheAccessor *legacyAccessor = [[MSIDLegacyTokenCacheAccessor alloc] initWithDataSource:dataSource otherCacheAccessors:nil factory:_oauth2Factory];
MSIDDefaultTokenCacheAccessor *defaultAccessor = [[MSIDDefaultTokenCacheAccessor alloc] initWithDataSource:dataSource otherCacheAccessors:@[legacyAccessor] factory:_oauth2Factory];

self.tokenCache = defaultAccessor;

Expand All @@ -233,7 +241,7 @@ - (id)initWithClientId:(NSString *)clientId
#else
__auto_type dataSource = MSIDMacTokenCache.defaultCache;

MSIDDefaultTokenCacheAccessor *defaultAccessor = [[MSIDDefaultTokenCacheAccessor alloc] initWithDataSource:dataSource otherCacheAccessors:nil factory:[MSIDAADV2Oauth2Factory new]];
MSIDDefaultTokenCacheAccessor *defaultAccessor = [[MSIDDefaultTokenCacheAccessor alloc] initWithDataSource:dataSource otherCacheAccessors:nil factory:_oauth2Factory];
self.tokenCache = defaultAccessor;
_webviewType = MSALWebviewTypeWKWebView;

Expand Down Expand Up @@ -550,7 +558,7 @@ - (void)acquireTokenForScopes:(NSArray<NSString *> *)scopes
{
MSALRequestParameters *params = [MSALRequestParameters new];

params.msidOAuthFactory = [MSIDAADV2Oauth2Factory new];
params.msidOAuthFactory = _oauth2Factory;
params.correlationId = correlationId ? correlationId : [NSUUID new];
params.logComponent = _component;
params.apiId = apiId;
Expand Down Expand Up @@ -637,7 +645,7 @@ - (void)acquireTokenSilentForScopes:(NSArray<NSString *> *)scopes
msidAuthority = [authorityFactory authorityFromUrl:msidAuthority.url rawTenant:account.homeAccountId.tenantId context:nil error:nil];

MSALRequestParameters* params = [MSALRequestParameters new];
params.msidOAuthFactory = [MSIDAADV2Oauth2Factory new];
params.msidOAuthFactory = _oauth2Factory;
params.correlationId = correlationId ? correlationId : [NSUUID new];
params.account = account;
params.apiId = apiId;
Expand Down
38 changes: 38 additions & 0 deletions MSAL/src/instance/MSALOauth2FactoryProducer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
//
// 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>

@class MSIDOauth2Factory;

@interface MSALOauth2FactoryProducer : NSObject

+ (nullable MSIDOauth2Factory *)msidOauth2FactoryForAuthority:(nonnull NSURL *)authority
context:(nullable id<MSIDRequestContext>)context
error:(NSError * _Nullable __autoreleasing * _Nullable)error;

@end
62 changes: 62 additions & 0 deletions MSAL/src/instance/MSALOauth2FactoryProducer.m
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 "MSALOauth2FactoryProducer.h"
#import "MSIDOauth2Factory.h"
#import "MSIDB2CAuthority.h"
#import "MSIDAADAuthority.h"
#import "MSIDAADV2Oauth2Factory.h"
#import "MSIDB2COauth2Factory.h"

@implementation MSALOauth2FactoryProducer

+ (MSIDOauth2Factory *)msidOauth2FactoryForAuthority:(NSURL *)authority
context:(id<MSIDRequestContext>)context
error:(NSError **)error
{
if (!authority)
{
if (error)
{
*error = MSIDCreateError(MSALErrorDomain, MSALErrorInvalidParameter, @"Provided authority url is not a valid authority.", nil, nil, nil, nil, nil);
MSID_LOG_ERROR(context, @"Provided authority url is not a valid authority.");
}

return nil;
}

if ([MSIDB2CAuthority isAuthorityFormatValid:authority context:context error:nil])
{
return [MSIDB2COauth2Factory new];
}

// Create AAD v2 factory for everything else, but in future we might want to further separate this out
// (e.g. ADFS, Google, Oauth2 etc...)
return [MSIDAADV2Oauth2Factory new];
}

@end
2 changes: 1 addition & 1 deletion MSAL/src/requests/MSALBaseRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef void(^MSALAuthorityCompletion)(BOOL resolved, NSError * _Nullable error)
@property (nullable) MSALTokenCacheItem *accessTokenItem;
@property (nonnull, readonly) MSALRequestParameters *parameters;
@property (nullable, nonatomic, readonly) MSIDDefaultTokenCacheAccessor *tokenCache;
@property (nullable, nonatomic, readonly) MSIDAADV2Oauth2Factory *oauth2Factory;
@property (nullable, nonatomic, readonly) MSIDOauth2Factory *oauth2Factory;

/* Returns the complete set of scopes to be sent out with a token request */
- (nonnull MSALScopes *)requestScopes:(nullable MSALScopes *)extraScopes;
Expand Down
17 changes: 15 additions & 2 deletions MSAL/src/requests/MSALBaseRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
@interface MSALBaseRequest()

@property (nullable, nonatomic) MSIDDefaultTokenCacheAccessor *tokenCache;
@property (nullable, nonatomic) MSIDAADV2Oauth2Factory *oauth2Factory;
@property (nullable, nonatomic) MSIDOauth2Factory *oauth2Factory;

@end

Expand Down Expand Up @@ -97,7 +97,20 @@ - (id)initWithParameters:(MSALRequestParameters *)parameters
}

_tokenCache = tokenCache;
_oauth2Factory = [MSIDAADV2Oauth2Factory new];

if (!_tokenCache)
{
REQUIRED_PARAMETER_ERROR(tokenCache, _parameters);
return nil;
}

_oauth2Factory = _parameters.msidOAuthFactory;

if (!_oauth2Factory)
{
REQUIRED_PARAMETER_ERROR(_parameters.msidOAuthFactory, _parameters);
return nil;
}

MSIDAADNetworkConfiguration.defaultConfiguration.aadApiVersion = @"v2.0";

Expand Down
1 change: 1 addition & 0 deletions MSAL/src/requests/MSALRequestParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
@property NSUUID *correlationId;
@property NSString *logComponent;
@property NSString *telemetryRequestId;
@property NSDictionary *appRequestMetadata;

@property (readonly) MSIDConfiguration *msidConfiguration;
@property MSIDOauth2Factory *msidOAuthFactory;
Expand Down
Loading

0 comments on commit a28ce2e

Please sign in to comment.