Skip to content

Commit cfb0d93

Browse files
authored
[minor][Feature]: Add ecs flags to disable pop & claims in browser core. (#1673)
## 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 - [ ] Feature work - [ ] Bug fix - [ ] Documentation - [x] 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
1 parent 67f0c7a commit cfb0d93

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

IdentityCore/src/MSIDConstants.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,16 @@ extern NSString * _Nonnull const MSID_FLIGHT_IS_BART_SUPPORTED;
243243
extern NSString * _Nonnull const MSID_FLIGHT_SPINNER_FIX;
244244

245245
extern NSString * _Nonnull const MSID_FLIGHT_ENABLE_QUERYING_STK;
246+
247+
/// Owner: sedemche
246248
extern NSString * _Nonnull const MSID_FLIGHT_USE_AUTOLAYOUT_FOR_LOADING_INDICATOR;
247249

250+
/// Owner: sedemche
251+
extern NSString * _Nonnull const MSID_FLIGHT_BROWSER_CORE_DISABLE_POP;
252+
253+
/// Owner: sedemche
254+
extern NSString * _Nonnull const MSID_FLIGHT_BROWSER_CORE_DISABLE_CLAIMS;
255+
248256
extern NSString * _Nonnull const MSID_DOMAIN_HINT_KEY;
249257

250258
extern NSString * _Nonnull const MSID_FLIGHT_ENABLE_THREAD_STARVATION;

IdentityCore/src/MSIDConstants.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101

102102
NSString *const MSID_FLIGHT_USE_AUTOLAYOUT_FOR_LOADING_INDICATOR = @"use_autolayout_for_loading_indicator";
103103

104+
NSString *const MSID_FLIGHT_BROWSER_CORE_DISABLE_POP = @"browser_core_disable_pop";
105+
106+
NSString *const MSID_FLIGHT_BROWSER_CORE_DISABLE_CLAIMS = @"browser_core_disable_claims";
107+
104108
NSString *const MSID_DOMAIN_HINT_KEY = @"domain_hint";
105109

106110
// This is SsoExt flow only flight

IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetTokenRequest.m

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#import "MSIDAuthenticationSchemePop.h"
3333
#import "MSIDAuthScheme.h"
3434
#import "MSIDClaimsRequest.h"
35+
#import "MSIDFlightManager.h"
3536

3637
NSString *const MSID_BROWSER_NATIVE_MESSAGE_CLIENT_ID_KEY = @"clientId";
3738
NSString *const MSID_BROWSER_NATIVE_MESSAGE_AUTHORITY_KEY = @"authority";
@@ -178,36 +179,45 @@ - (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError *__au
178179
// It is optional param, if nil -- set it to 'true' by default.
179180
_canShowUI = canShowUIValue ? [requestJson msidBoolObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CAN_SHOW_UI_KEY] : YES;
180181

181-
NSString *reqCnf = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_REQUEST_CONFIRMATION_KEY] ?: [_extraParameters msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_REQUEST_CONFIRMATION_KEY];
182-
NSString *tokenType = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_TOKEN_TYPE_KEY] ?: [_extraParameters msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_TOKEN_TYPE_KEY];
183-
tokenType = tokenType.capitalizedString;
182+
BOOL disablePop = [MSIDFlightManager.sharedInstance boolForKey:MSID_FLIGHT_BROWSER_CORE_DISABLE_POP];
184183

185-
186-
if (MSIDAuthSchemeTypeFromString(tokenType) == MSIDAuthSchemePop)
184+
if (!disablePop)
187185
{
188-
NSMutableDictionary *schemeParams = [NSMutableDictionary new];
189-
schemeParams[MSID_OAUTH2_TOKEN_TYPE] = tokenType;
190-
schemeParams[MSID_OAUTH2_REQUEST_CONFIRMATION] = reqCnf;
186+
NSString *reqCnf = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_REQUEST_CONFIRMATION_KEY] ?: [_extraParameters msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_REQUEST_CONFIRMATION_KEY];
187+
NSString *tokenType = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_TOKEN_TYPE_KEY] ?: [_extraParameters msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_TOKEN_TYPE_KEY];
188+
tokenType = tokenType.capitalizedString;
191189

192-
_authScheme = [[MSIDAuthenticationSchemePop alloc] initWithSchemeParameters:schemeParams];
190+
if (MSIDAuthSchemeTypeFromString(tokenType) == MSIDAuthSchemePop)
191+
{
192+
NSMutableDictionary *schemeParams = [NSMutableDictionary new];
193+
schemeParams[MSID_OAUTH2_TOKEN_TYPE] = tokenType;
194+
schemeParams[MSID_OAUTH2_REQUEST_CONFIRMATION] = reqCnf;
195+
196+
_authScheme = [[MSIDAuthenticationSchemePop alloc] initWithSchemeParameters:schemeParams];
197+
}
193198
}
194199

195200
if (!_authScheme)
196201
{
197202
_authScheme = [MSIDAuthenticationScheme new]; // Bearer by default.
198203
}
199-
200-
NSString *claims = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CLAIMS_KEY] ?: [_extraParameters msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CLAIMS_KEY];
201204

202-
if (claims)
205+
BOOL disableClaims = [MSIDFlightManager.sharedInstance boolForKey:MSID_FLIGHT_BROWSER_CORE_DISABLE_CLAIMS];
206+
207+
if (!disableClaims)
203208
{
204-
NSDictionary *claimsJson = [claims msidJson];
209+
NSString *claims = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CLAIMS_KEY] ?: [_extraParameters msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CLAIMS_KEY];
205210

206-
NSError *claimsError;
207-
_claimsRequest = [[MSIDClaimsRequest alloc] initWithJSONDictionary:claimsJson error:&claimsError];
208-
if (claimsError)
211+
if (claims)
209212
{
210-
MSID_LOG_WITH_CTX(MSIDLogLevelWarning, nil, @"Failed to create claims request. Claims: %@", MSID_PII_LOG_MASKABLE(claimsJson));
213+
NSDictionary *claimsJson = [claims msidJson];
214+
215+
NSError *claimsError;
216+
_claimsRequest = [[MSIDClaimsRequest alloc] initWithJSONDictionary:claimsJson error:&claimsError];
217+
if (claimsError)
218+
{
219+
MSID_LOG_WITH_CTX(MSIDLogLevelWarning, nil, @"Failed to create claims request. Claims: %@", MSID_PII_LOG_MASKABLE(claimsJson));
220+
}
211221
}
212222
}
213223

0 commit comments

Comments
 (0)