Skip to content

Commit 361d005

Browse files
agubuzomaximusMaximus Agubuzo
andauthored
[minor][Feature]: Introduce UFIC into API contract (#1670)
## PR Title Format **Required Format:** `[Keyword1] [Keyword2]: Description` - **Keyword1:** `major`, `minor`, or `patch` (case-insensitive) - **Keyword2:** `feature`, `bugfix`, `engg`, or `tests` (case-insensitive) **Examples:** - `[MAJOR] [Feature]: new API` - `[minor] [bugfix]: fix crash` - `[PATCH][tests]:add coverage` ## Proposed changes Describe what this PR is trying to do. ## Type of change - [X] Feature work - [ ] Bug fix - [ ] Documentation - [ ] Engineering change - [ ] Test - [ ] Logging/Telemetry ## Risk - [ ] High – Errors could cause MAJOR regression of many scenarios. (Example: new large features or high level infrastructure changes) - [ ] Medium – Errors could cause regression of 1 or more scenarios. (Example: somewhat complex bug fixes, small new features) - [X] Small – No issues are expected. (Example: Very small bug fixes, string changes, or configuration settings changes) ## Additional information --------- Co-authored-by: Maximus Agubuzo <maximusagubuzo@MacBook-Air-6.local>
1 parent 784eec3 commit 361d005

File tree

9 files changed

+32
-2
lines changed

9 files changed

+32
-2
lines changed

IdentityCore/src/MSIDConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ extern NSString * _Nonnull const MSID_APP_VER_KEY;
133133
extern NSString * _Nonnull const MSID_CCS_HINT_KEY;
134134
extern NSString * _Nonnull const MSID_WEBAUTH_IGNORE_SSO_KEY;
135135
extern NSString * _Nonnull const MSID_WEBAUTH_REFRESH_TOKEN_KEY;
136+
extern NSString * _Nonnull const MSID_USER_FEDERATED_IDENTITY_CREDENTIAL_KEY;
136137

137138
extern NSString * _Nonnull const MSID_DEFAULT_FAMILY_ID;
138139
extern NSString * _Nonnull const MSID_ADAL_SDK_NAME;

IdentityCore/src/MSIDConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
NSString *const MSID_CCS_HINT_KEY = @"X-AnchorMailbox";
3636
NSString *const MSID_WEBAUTH_IGNORE_SSO_KEY = @"x-ms-sso-Ignore-SSO";
3737
NSString *const MSID_WEBAUTH_REFRESH_TOKEN_KEY = @"x-ms-sso-RefreshToken";
38+
NSString *const MSID_USER_FEDERATED_IDENTITY_CREDENTIAL_KEY = @"x-ms-UserFederatedIdentityCredential";
3839

3940
NSString *const MSID_DEFAULT_FAMILY_ID = @"1";
4041
NSString *const MSID_ADAL_SDK_NAME = @"adal-objc";

IdentityCore/src/broker_operation/request/interactive_token_request/MSIDBrokerOperationInteractiveTokenRequest.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ + (instancetype)tokenRequestWithParameters:(MSIDInteractiveTokenRequestParameter
5555
request.promptType = parameters.promptType;
5656
request.extraQueryParameters = [parameters allAuthorizeRequestExtraParametersWithMetadata:NO];
5757
request.extraScopesToConsent = parameters.extraScopesToConsent;
58+
request.userFederatedIdentityToken = parameters.userFederatedIdentityToken;
5859

5960
return request;
6061
}
@@ -97,6 +98,11 @@ - (NSDictionary *)jsonDictionary
9798
json[MSID_BROKER_PROMPT_KEY] = promptString;
9899
json[MSID_BROKER_EXTRA_CONSENT_SCOPES_KEY] = self.extraScopesToConsent;
99100

101+
if (self.userFederatedIdentityToken)
102+
{
103+
json[MSID_USER_FEDERATED_IDENTITY_CREDENTIAL_KEY] = self.userFederatedIdentityToken;
104+
}
105+
100106
return json;
101107
}
102108

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
4747
@property (nonatomic) NSString *webPageUri;
4848
@property (nonatomic, nullable) NSString *accountHomeTenantId;
4949
@property (nonatomic, nullable) NSString *clientSku;
50+
@property (nonatomic, nullable) NSString *userFederatedIdentityToken;
5051
@property (nonatomic) BOOL skipValidateResultAccount;
5152
@property (nonatomic) BOOL forceRefresh;
5253
@property (nonatomic) BOOL ignoreScopeValidation;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ - (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError *__au
9696

9797
_instanceAware = [json msidBoolObjectForKey:MSID_BROKER_INSTANCE_AWARE_KEY];
9898

99+
_userFederatedIdentityToken = [json msidStringObjectForKey:MSID_USER_FEDERATED_IDENTITY_CREDENTIAL_KEY];
100+
99101
NSString *enrollmentIdsStr = [json msidStringObjectForKey:MSID_BROKER_INTUNE_ENROLLMENT_IDS_KEY];
100102
if (enrollmentIdsStr)
101103
{
@@ -146,6 +148,7 @@ - (NSDictionary *)jsonDictionary
146148
json[@"web_page_uri"] = self.webPageUri;
147149
json[MSID_PROVIDER_TYPE_JSON_KEY] = MSIDProviderTypeToString(self.providerType);
148150
json[MSID_BROKER_EXTRA_OIDC_SCOPES_KEY] = self.oidcScope;
151+
json[MSID_USER_FEDERATED_IDENTITY_CREDENTIAL_KEY] = self.userFederatedIdentityToken;
149152
json[MSID_BROKER_EXTRA_QUERY_PARAM_KEY] = [self.extraQueryParameters msidWWWFormURLEncode];
150153
json[MSID_BROKER_INSTANCE_AWARE_KEY] = [@(self.instanceAware) stringValue];
151154
json[MSID_BROKER_INTUNE_ENROLLMENT_IDS_KEY] = [self.enrollmentIds msidJSONSerializeWithContext:nil];

IdentityCore/src/controllers/broker/MSIDSSOExtensionInteractiveTokenRequestController.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ - (void)acquireToken:(MSIDRequestCompletionBlock)completionBlock
7777

7878
completionBlock(result, error);
7979
};
80-
8180

8281
[self acquireTokenWithRequest:request completionBlock:completionBlockWrapper];
8382
}

IdentityCore/src/oauth2/MSIDWebviewFactory.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ - (MSIDAuthorizeWebRequestConfiguration *)authorizeWebRequestConfigurationWithRe
299299
#if MSAL_JS_AUTOMATION
300300
configuration.clientAutomationScript = [[parameters allAuthorizeRequestExtraParametersWithMetadata:YES] objectForKey:@"script"];
301301
#endif
302-
302+
303303
configuration.customHeaders = parameters.customWebviewHeaders;
304304
configuration.parentController = parameters.parentViewController;
305305
configuration.prefersEphemeralWebBrowserSession = parameters.prefersEphemeralWebBrowserSession;
@@ -308,6 +308,15 @@ - (MSIDAuthorizeWebRequestConfiguration *)authorizeWebRequestConfigurationWithRe
308308
#if TARGET_OS_IPHONE
309309
configuration.presentationType = parameters.presentationType;
310310
#endif
311+
312+
if (!configuration.customHeaders[MSID_USER_FEDERATED_IDENTITY_CREDENTIAL_KEY])
313+
{
314+
NSMutableDictionary *mutableHeaders = configuration.customHeaders ? [configuration.customHeaders mutableCopy] : [NSMutableDictionary dictionary];
315+
316+
mutableHeaders[MSID_USER_FEDERATED_IDENTITY_CREDENTIAL_KEY] = parameters.userFederatedIdentityToken;
317+
318+
configuration.customHeaders = mutableHeaders;
319+
}
311320

312321
return configuration;
313322
}

IdentityCore/src/parameters/MSIDInteractiveTokenRequestParameters.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
3737
@property (nonatomic) NSDictionary *extraAuthorizeURLQueryParameters;
3838
@property (nonatomic) BOOL enablePkce;
3939
@property (nonatomic) MSIDBrokerInvocationOptions *brokerInvocationOptions;
40+
@property (nullable, nonatomic) id<MSIDCustomHeaderProviding> crossDomainHeaderProvider;
41+
// Additional request parameter that will be utilized by OneAuth during internal automation testing. When available will be passed to web view to be consumed by ESTS as a form of MFA.
42+
@property (nonatomic, nullable) NSString *userFederatedIdentityToken;
4043
@property (nullable, nonatomic) id<MSIDCustomHeaderProviding> prtHeaderProvider;
4144

4245
- (NSOrderedSet *)allAuthorizeRequestScopes;

IdentityCore/src/requests/MSIDInteractiveAuthorizationCodeRequest.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ - (void)handleWebReponseV2:(MSIDWebviewResponse *)response error:(NSError *)erro
216216
returnErrorBlock(localError);
217217
return;
218218
}
219+
220+
if (self.requestParameters.userFederatedIdentityToken)
221+
{
222+
NSMutableDictionary *customHeaders = [_webViewConfiguration.customHeaders mutableCopy] ?: [NSMutableDictionary new];
223+
customHeaders[@"x-ms-UserFederatedIdentityCredential"] = self.requestParameters.userFederatedIdentityToken;
224+
self.webViewConfiguration.customHeaders = customHeaders;
225+
}
219226

220227
__typeof__(self) __weak weakSelf = self;
221228
[operation invokeWithRequestParameters:self.requestParameters

0 commit comments

Comments
 (0)