Skip to content

Commit

Permalink
Add canShowUI property to GetToken request (#1415)
Browse files Browse the repository at this point in the history
* Add canShowUI property.

* modified:   changelog.txt

* Support string and number for bool.
  • Loading branch information
antrix1989 authored Sep 4, 2024
1 parent 338a162 commit ef53d43
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ NS_ASSUME_NONNULL_BEGIN
/// Contains info about componenets involved into the flow. Used for telemetry.
@property (nonatomic) NSString *platformSequence;

/// When this flag is 'false', ui is not allowed. If we cannot acquire tokens silently, UI_NOT_ALLOWED status should be returned to the browser. This param is optional and by defrault it is 'true'.
@property (nonatomic) BOOL canShowUI;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
NSString *const MSID_BROWSER_NATIVE_MESSAGE_EXTRA_PARAMETERS_KEY = @"extraParameters";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_REQUEST_KEY = @"request";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_PLATFORM_SEQUENCE_KEY = @"x-client-xtra-sku";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_CAN_SHOW_UI_KEY = @"canShowUI";

@implementation MSIDBrowserNativeMessageGetTokenRequest

Expand Down Expand Up @@ -121,6 +122,10 @@ - (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError *__au
_correlationId = uuidString ? [[NSUUID alloc] initWithUUIDString:uuidString] : [NSUUID UUID];
_platformSequence = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_PLATFORM_SEQUENCE_KEY];

id canShowUIValue = requestJson[MSID_BROWSER_NATIVE_MESSAGE_CAN_SHOW_UI_KEY];
// It is optional param, if nil -- set it to 'true' by default.
_canShowUI = canShowUIValue ? [requestJson msidBoolObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CAN_SHOW_UI_KEY] : YES;

return self;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ - (void)testInitWithJSONDictionary_whenJsonValidAndAllFieldsProvided_shouldInit
@"correlationId": @"9BBCA391-33A9-4EC9-A00E-A0FBFA71013D",
@"prompt": @"login",
@"isSts": @(YES),
@"canShowUI": @(NO),
@"nonce": @"e98aba90-bc47-4ff9-8809-b6e1c7e7cd47",
@"state": @"state1",
@"loginHint": @"user@microsoft.com",
Expand All @@ -94,6 +95,7 @@ - (void)testInitWithJSONDictionary_whenJsonValidAndAllFieldsProvided_shouldInit
XCTAssertEqualObjects(@"9BBCA391-33A9-4EC9-A00E-A0FBFA71013D", request.correlationId.UUIDString);
XCTAssertEqual(MSIDPromptTypeLogin, request.prompt);
XCTAssertTrue(request.isSts);
XCTAssertFalse(request.canShowUI);
XCTAssertEqualObjects(@"e98aba90-bc47-4ff9-8809-b6e1c7e7cd47", request.nonce);
XCTAssertEqualObjects(@"state1", request.state);
XCTAssertEqualObjects(@"user@microsoft.com", request.loginHint);
Expand All @@ -120,6 +122,7 @@ - (void)testInitWithJSONDictionary_whenJsonValidAndRequiredOnlyFieldsProvided_sh
XCTAssertEqualObjects(@"29a788ca-7bcf-4732-b23c-c8d294347e5b", request.clientId);
XCTAssertEqualObjects(@"user.read openid profile offline_access", request.scopes);
XCTAssertEqualObjects(@"https://login.microsoft.com", request.redirectUri);
XCTAssertTrue(request.canShowUI);
XCTAssertNotNil(request.correlationId.UUIDString);
}

Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[TBD]
* Increased macOS minimum version to 10.15 (#2220)
* Add canShowUI property to GetToken request (#1415)

Version 1.7.39
* Fix cert auth invalid request (hotfix) (#1409)
Expand Down

0 comments on commit ef53d43

Please sign in to comment.