Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Remove identity core classes from public api (AzureAD#1158)
Browse files Browse the repository at this point in the history
* Remove identity core classes from public api.

* Add MSALParameters to public headers of static libs.

* Add missed files to static lib targets.

* Add missed file to static lib target.

* Update changelog.
  • Loading branch information
antrix1989 authored Jan 6, 2021
1 parent c0307e0 commit cde2b50
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 46 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## TBD
## TBD
* Removed identity core classes from public api (#1158).
* Fixed possible deadlock caused by thread explosion
* Added pipeline configuration to generate framework for SPM & automate MSAL release.

Expand Down
38 changes: 38 additions & 0 deletions MSAL/MSAL.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions MSAL/src/MSALAuthenticationSchemeBearer+Internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// 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 <MSAL/MSAL.h>
#import "MSALAuthenticationSchemeBearer.h"
#import "MSALAuthenticationSchemeProtocolInternal.h"

NS_ASSUME_NONNULL_BEGIN

@interface MSALAuthenticationSchemeBearer () <MSALAuthenticationSchemeProtocolInternal>

@end

NS_ASSUME_NONNULL_END
16 changes: 10 additions & 6 deletions MSAL/src/MSALAuthenticationSchemeBearer.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//
//------------------------------------------------------------------------------

#import "MSALAuthenticationSchemeBearer.h"
#import "MSALAuthenticationSchemeBearer+Internal.h"
#import "MSIDAuthenticationScheme.h"
#import "MSALAuthScheme.h"
#import "MSIDAccessToken.h"
Expand All @@ -45,6 +45,15 @@ - (instancetype)init
return self;
}

#pragma mark - MSALAuthenticationSchemeProtocol

- (NSString *)authenticationScheme
{
return MSALParameterStringForAuthScheme(self.scheme);
}

#pragma mark - MSALAuthenticationSchemeProtocolInternal

- (MSIDAuthenticationScheme *)createMSIDAuthenticationSchemeWithParams:(nullable NSDictionary *)params
{
return [[MSIDAuthenticationScheme alloc] initWithSchemeParameters:params];
Expand All @@ -60,11 +69,6 @@ - (NSString *)getClientAccessToken:(MSIDAccessToken *)accessToken popManager:(nu
return accessToken.accessToken;
}

- (NSString *)authenticationScheme
{
return MSALParameterStringForAuthScheme(self.scheme);
}

- (NSString *)getAuthorizationHeader:(NSString *)accessToken
{
return [NSString stringWithFormat:@"%@%@%@", self.authenticationScheme, keyDelimiter, accessToken];
Expand Down
36 changes: 36 additions & 0 deletions MSAL/src/MSALAuthenticationSchemePop+Internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// 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 <MSAL/MSAL.h>
#import "MSALAuthenticationSchemePop.h"
#import "MSALAuthenticationSchemeProtocolInternal.h"

NS_ASSUME_NONNULL_BEGIN

@interface MSALAuthenticationSchemePop () <MSALAuthenticationSchemeProtocolInternal>

@end

NS_ASSUME_NONNULL_END
14 changes: 8 additions & 6 deletions MSAL/src/MSALAuthenticationSchemePop.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//
//------------------------------------------------------------------------------

#import "MSALAuthenticationSchemePop.h"
#import "MSALAuthenticationSchemePop+Internal.h"
#import "MSIDAuthenticationSchemePop.h"
#import "MSALHttpMethod.h"
#import "MSIDDevicePopManager.h"
Expand Down Expand Up @@ -65,6 +65,13 @@ - (instancetype)initWithHttpMethod:(MSALHttpMethod)httpMethod
return self;
}

- (NSString *)authenticationScheme
{
return MSALParameterStringForAuthScheme(self.scheme);
}

#pragma mark - MSALAuthenticationSchemeProtocolInternal

- (MSIDAuthenticationScheme *)createMSIDAuthenticationSchemeWithParams:(nullable NSDictionary *)params
{
return [[MSIDAuthenticationSchemePop alloc] initWithSchemeParameters:params];
Expand Down Expand Up @@ -118,11 +125,6 @@ - (nullable NSString *)getClientAccessToken:(MSIDAccessToken *)accessToken popMa
return signedAccessToken;
}

- (NSString *)authenticationScheme
{
return MSALParameterStringForAuthScheme(self.scheme);
}

- (NSString *)getAuthorizationHeader:(NSString *)accessToken
{
return [NSString stringWithFormat:@"%@%@%@", self.authenticationScheme, keyDelimiter, accessToken];
Expand Down
48 changes: 48 additions & 0 deletions MSAL/src/MSALAuthenticationSchemeProtocolInternal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// 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>

NS_ASSUME_NONNULL_BEGIN

@class MSIDDevicePopManager;
@class MSIDAccessToken;
@class MSIDAuthenticationScheme;

@protocol MSALAuthenticationSchemeProtocolInternal <NSObject>

- (MSIDAuthenticationScheme *)createMSIDAuthenticationSchemeWithParams:(nullable NSDictionary *)params;

- (nullable NSDictionary *)getSchemeParameters:(nonnull MSIDDevicePopManager *)popManager;

- (nullable NSString *)getAuthorizationHeader:(nonnull NSString *)accessToken;

- (nullable NSString *)getClientAccessToken:(MSIDAccessToken *)accessToken
popManager:(nullable MSIDDevicePopManager *)popManager
error:(NSError **)error;


@end

NS_ASSUME_NONNULL_END
39 changes: 35 additions & 4 deletions MSAL/src/MSALPublicClientApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
#import "MSALPublicClientApplication+SingleAccount.h"
#import "MSALDeviceInfoProvider.h"
#import "MSALAuthenticationSchemeProtocol.h"
#import "MSALAuthenticationSchemeProtocolInternal.h"
#import "MSIDCurrentRequestTelemetry.h"
#import "MSIDCacheConfig.h"
#import "MSIDDevicePopManager.h"
Expand Down Expand Up @@ -817,8 +818,16 @@ - (void)acquireTokenSilentWithParameters:(MSALSilentTokenParameters *)parameters

MSIDRequestType requestType = [self requestType];

NSDictionary *schemeParams = [parameters.authenticationScheme getSchemeParameters:self.popManager];
MSIDAuthenticationScheme *msidAuthScheme = [parameters.authenticationScheme createMSIDAuthenticationSchemeWithParams:schemeParams];
id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>authenticationScheme = [self getInternalAuthenticationSchemeProtocolForScheme:parameters.authenticationScheme withError:&msidError];

if (msidError)
{
block(nil, msidError, nil);
return;
}

NSDictionary *schemeParams = [authenticationScheme getSchemeParameters:self.popManager];
MSIDAuthenticationScheme *msidAuthScheme = [authenticationScheme createMSIDAuthenticationSchemeWithParams:schemeParams];

// add known authorities here.
MSIDRequestParameters *msidParams = [[MSIDRequestParameters alloc] initWithAuthority:requestAuthority
Expand Down Expand Up @@ -1104,8 +1113,16 @@ - (void)acquireTokenWithParameters:(MSALInteractiveTokenParameters *)parameters

#endif

NSDictionary *schemeParams = [parameters.authenticationScheme getSchemeParameters:self.popManager];
MSIDAuthenticationScheme *msidAuthScheme = [parameters.authenticationScheme createMSIDAuthenticationSchemeWithParams:schemeParams];
id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>authenticationScheme = [self getInternalAuthenticationSchemeProtocolForScheme:parameters.authenticationScheme withError:&msidError];

if (msidError)
{
block(nil, msidError, nil);
return;
}

NSDictionary *schemeParams = [authenticationScheme getSchemeParameters:self.popManager];
MSIDAuthenticationScheme *msidAuthScheme = [authenticationScheme createMSIDAuthenticationSchemeWithParams:schemeParams];

MSIDInteractiveTokenRequestParameters *msidParams =
[[MSIDInteractiveTokenRequestParameters alloc] initWithAuthority:requestAuthority
Expand Down Expand Up @@ -1550,6 +1567,20 @@ + (NSString *)sdkVersion

#pragma mark - Private

- (id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)getInternalAuthenticationSchemeProtocolForScheme:(id<MSALAuthenticationSchemeProtocol>)authenticationScheme
withError:(NSError **)error
{
if (![authenticationScheme conformsToProtocol:@protocol(MSALAuthenticationSchemeProtocolInternal)])
{
NSError *msidError = MSIDCreateError(MSIDErrorDomain, MSIDErrorInternal, @"authenticationScheme doesn't support MSALAuthenticationSchemeProtocolInternal protocol.", nil, nil, nil, nil, nil, YES);
if (error) *error = msidError;

return nil;
}

return (id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authenticationScheme;
}

- (MSIDRequestType)requestType
{
MSIDRequestType requestType = MSIDRequestBrokeredType;
Expand Down
3 changes: 2 additions & 1 deletion MSAL/src/MSALResult+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@

@class MSIDTokenResult;
@protocol MSALAuthenticationSchemeProtocol;
@protocol MSALAuthenticationSchemeProtocolInternal;
@class MSIDDevicePopManager;

@interface MSALResult (Internal)

+ (MSALResult *)resultWithMSIDTokenResult:(MSIDTokenResult *)tokenResult
authority:(MSALAuthority *)authority
authScheme:(id<MSALAuthenticationSchemeProtocol>)authScheme
authScheme:(id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authScheme
popManager:(MSIDDevicePopManager *)popManager
error:(NSError **)error;

Expand Down
7 changes: 4 additions & 3 deletions MSAL/src/MSALResult.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
#import "MSALTenantProfile+Internal.h"
#import "MSIDDevicePopManager.h"
#import "MSALAuthenticationSchemeProtocol.h"
#import "MSALAuthenticationSchemeProtocolInternal.h"

@interface MSALResult()

@property id<MSALAuthenticationSchemeProtocol> authScheme;
@property id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal> authScheme;

@end

Expand Down Expand Up @@ -77,7 +78,7 @@ + (MSALResult *)resultWithAccessToken:(NSString *)accessToken
scopes:(NSArray<NSString *> *)scopes
authority:(MSALAuthority *)authority
correlationId:(NSUUID *)correlationId
authScheme:(id<MSALAuthenticationSchemeProtocol>)authScheme
authScheme:(id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authScheme
{
MSALResult *result = [MSALResult new];
result->_accessToken = accessToken;
Expand All @@ -97,7 +98,7 @@ + (MSALResult *)resultWithAccessToken:(NSString *)accessToken

+ (MSALResult *)resultWithMSIDTokenResult:(MSIDTokenResult *)tokenResult
authority:(MSALAuthority *)authority
authScheme:(id<MSALAuthenticationSchemeProtocol>)authScheme
authScheme:(id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authScheme
popManager:(MSIDDevicePopManager *)popManager
error:(NSError **)error
{
Expand Down
2 changes: 1 addition & 1 deletion MSAL/src/instance/oauth2/MSALOauth2Provider.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (instancetype)initWithClientId:(NSString *)clientId
}

- (MSALResult *)resultWithTokenResult:(MSIDTokenResult *)tokenResult
authScheme:(id<MSALAuthenticationSchemeProtocol>)authScheme
authScheme:(id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authScheme
popManager:(MSIDDevicePopManager *)popManager
error:(NSError **)error
{
Expand Down
2 changes: 1 addition & 1 deletion MSAL/src/instance/oauth2/aad/MSALAADOauth2Provider.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ @implementation MSALAADOauth2Provider
#pragma mark - Public

- (MSALResult *)resultWithTokenResult:(MSIDTokenResult *)tokenResult
authScheme:(id<MSALAuthenticationSchemeProtocol>)authScheme
authScheme:(id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authScheme
popManager:(MSIDDevicePopManager *)popManager
error:(NSError **)error
{
Expand Down
2 changes: 1 addition & 1 deletion MSAL/src/instance/oauth2/adfs/MSALADFSOauth2Provider.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ @implementation MSALADFSOauth2Provider
#pragma mark - Public

- (MSALResult *)resultWithTokenResult:(MSIDTokenResult *)tokenResult
authScheme:(id<MSALAuthenticationSchemeProtocol>)authScheme
authScheme:(id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authScheme
popManager:(MSIDDevicePopManager *)popManager
error:(NSError **)error
{
Expand Down
2 changes: 1 addition & 1 deletion MSAL/src/instance/oauth2/b2c/MSALB2COauth2Provider.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ @implementation MSALB2COauth2Provider
#pragma mark - Public

- (MSALResult *)resultWithTokenResult:(MSIDTokenResult *)tokenResult
authScheme:(id<MSALAuthenticationSchemeProtocol>)authScheme
authScheme:(id<MSALAuthenticationSchemeProtocol, MSALAuthenticationSchemeProtocolInternal>)authScheme
popManager:(MSIDDevicePopManager *)popManager
error:(NSError **)error
{
Expand Down
14 changes: 0 additions & 14 deletions MSAL/src/public/MSALAuthenticationSchemeProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

#import <Foundation/Foundation.h>

@class MSIDDevicePopManager;
@class MSIDAccessToken;
@class MSIDAuthenticationScheme;

NS_ASSUME_NONNULL_BEGIN

@protocol MSALAuthenticationSchemeProtocol <NSObject>
Expand All @@ -39,16 +35,6 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, readonly) NSString *authenticationScheme;

- (MSIDAuthenticationScheme *)createMSIDAuthenticationSchemeWithParams:(nullable NSDictionary *)params;

- (nullable NSDictionary *)getSchemeParameters:(nonnull MSIDDevicePopManager *)popManager;

- (nullable NSString *)getAuthorizationHeader:(nonnull NSString *)accessToken;

- (nullable NSString *)getClientAccessToken:(MSIDAccessToken *)accessToken
popManager:(nullable MSIDDevicePopManager *)popManager
error:(NSError **)error;

@end

NS_ASSUME_NONNULL_END
2 changes: 0 additions & 2 deletions MSAL/src/public/MSALAuthority.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

#import <Foundation/Foundation.h>

@protocol MSIDRequestContext;

/**
MSALAuthority represents an identity provider instance that MSAL can use to obtain tokens. For AAD it is of the form https://aad_instance/aad_tenant, where aad_instance is the
directory host (e.g. https://login.microsoftonline.com) and aad_tenant is a identifier within the directory itself (e.g. a domain associated to the tenant, such as contoso.onmicrosoft.com, or the GUID representing the TenantID property of the directory)
Expand Down
Loading

0 comments on commit cde2b50

Please sign in to comment.