diff --git a/IdentityCore/src/MSIDBrokerConstants.h b/IdentityCore/src/MSIDBrokerConstants.h index 203c7e19d..a350c11d6 100644 --- a/IdentityCore/src/MSIDBrokerConstants.h +++ b/IdentityCore/src/MSIDBrokerConstants.h @@ -69,6 +69,7 @@ extern NSString * _Nonnull const MSID_BROKER_DEVICE_MODE_KEY; extern NSString * _Nonnull const MSID_BROKER_SSO_EXTENSION_MODE_KEY; extern NSString * _Nonnull const MSID_BROKER_WPJ_STATUS_KEY; extern NSString * _Nonnull const MSID_BROKER_BROKER_VERSION_KEY; +extern NSString * _Nonnull const MSID_SSO_PROVIDER_TYPE_KEY; extern NSString * _Nonnull const MSID_BROKER_IS_PERFORMING_CBA; extern NSString * _Nonnull const MSID_ADAL_BROKER_MESSAGE_VERSION; extern NSString * _Nonnull const MSID_MSAL_BROKER_MESSAGE_VERSION; diff --git a/IdentityCore/src/MSIDBrokerConstants.m b/IdentityCore/src/MSIDBrokerConstants.m index 5c3b48567..c4dbedfa9 100644 --- a/IdentityCore/src/MSIDBrokerConstants.m +++ b/IdentityCore/src/MSIDBrokerConstants.m @@ -66,6 +66,7 @@ NSString *const MSID_BROKER_SSO_EXTENSION_MODE_KEY = @"sso_extension_mode"; NSString *const MSID_BROKER_WPJ_STATUS_KEY = @"wpj_status"; NSString *const MSID_BROKER_BROKER_VERSION_KEY = @"broker_version"; +NSString *const MSID_SSO_PROVIDER_TYPE_KEY = @"sso_provider_type"; NSString *const MSID_BROKER_IS_PERFORMING_CBA = @"broker_is_performing_cba"; NSString *const MSID_ADAL_BROKER_MESSAGE_VERSION = @"2"; NSString *const MSID_MSAL_BROKER_MESSAGE_VERSION = @"3"; diff --git a/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.h b/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.h index 0ddee1c20..2d4395a11 100644 --- a/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.h +++ b/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.h @@ -55,6 +55,12 @@ typedef NS_ENUM(NSInteger, MSIDPreferredAuthMethod) MSIDPreferredAuthMethodQRPIN }; +typedef NS_ENUM(NSInteger, MSIDSsoProviderType) +{ + MSIDUnknownSsoProvider = 0, + MSIDMacBrokerSsoProvider, + MSIDCompanyPortalSsoProvider +}; NS_ASSUME_NONNULL_BEGIN @@ -64,6 +70,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) MSIDSSOExtensionMode ssoExtensionMode; @property (nonatomic) MSIDWorkPlaceJoinStatus wpjStatus; @property (nonatomic, nullable) NSString *brokerVersion; +@property (nonatomic) MSIDSsoProviderType ssoProviderType; @property (nonatomic) NSDictionary *additionalExtensionData; @property (nonatomic) MSIDPreferredAuthMethod preferredAuthConfig; @@ -77,7 +84,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithDeviceMode:(MSIDDeviceMode)deviceMode ssoExtensionMode:(MSIDSSOExtensionMode)ssoExtensionMode isWorkPlaceJoined:(BOOL)isWorkPlaceJoined - brokerVersion:(NSString *)brokerVersion; + brokerVersion:(NSString *)brokerVersion + ssoProviderType:(MSIDSsoProviderType)ssoProviderType; @end diff --git a/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.m b/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.m index 1df2f3d6f..1e6273b4f 100644 --- a/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.m +++ b/IdentityCore/src/broker_operation/response/MSIDDeviceInfo.m @@ -31,11 +31,11 @@ @implementation MSIDDeviceInfo - - (instancetype)initWithDeviceMode:(MSIDDeviceMode)deviceMode ssoExtensionMode:(MSIDSSOExtensionMode)ssoExtensionMode isWorkPlaceJoined:(BOOL)isWorkPlaceJoined brokerVersion:(NSString *)brokerVersion + ssoProviderType:(MSIDSsoProviderType)ssoProviderType { self = [super init]; @@ -45,6 +45,7 @@ - (instancetype)initWithDeviceMode:(MSIDDeviceMode)deviceMode _ssoExtensionMode = ssoExtensionMode; _wpjStatus = isWorkPlaceJoined ? MSIDWorkPlaceJoinStatusJoined : MSIDWorkPlaceJoinStatusNotJoined; _brokerVersion = brokerVersion; + _ssoProviderType = ssoProviderType; } return self; @@ -66,6 +67,7 @@ - (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(__unused NSEr #if TARGET_OS_OSX _platformSSOStatus = [self platformSSOStatusEnumFromString:[json msidStringObjectForKey:MSID_PLATFORM_SSO_STATUS_KEY]]; + _ssoProviderType = [self ssoProviderTypeEnumFromString:[json msidStringObjectForKey:MSID_SSO_PROVIDER_TYPE_KEY]]; #endif NSString *jsonDataString = [json msidStringObjectForKey:MSID_ADDITIONAL_EXTENSION_DATA_KEY]; @@ -97,6 +99,7 @@ - (NSDictionary *)jsonDictionary json[MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY] = [self preferredAuthConfigurationStringFromEnum:self.preferredAuthConfig]; #if TARGET_OS_OSX json[MSID_PLATFORM_SSO_STATUS_KEY] = [self platformSSOStatusStringFromEnum:self.platformSSOStatus]; + json[MSID_SSO_PROVIDER_TYPE_KEY] = [self ssoProviderTypeStringFromEnum:self.ssoProviderType]; #endif json[MSID_ADDITIONAL_EXTENSION_DATA_KEY] = [self.additionalExtensionData msidJSONSerializeWithContext:nil]; if (self.extraDeviceInfo) @@ -215,4 +218,25 @@ - (MSIDPreferredAuthMethod)preferredAuthConfigurationEnumFromString:(NSString *) return MSIDPreferredAuthMethodNotConfigured; } +- (NSString *)ssoProviderTypeStringFromEnum:(MSIDSsoProviderType)deviceMode +{ + switch (deviceMode) + { + case MSIDCompanyPortalSsoProvider: + return @"companyPortal"; + case MSIDMacBrokerSsoProvider: + return @"macBroker"; + default: + return @"unknown"; + } +} + +- (MSIDSsoProviderType)ssoProviderTypeEnumFromString:(NSString *)deviceModeString +{ + if ([deviceModeString isEqualToString:@"companyPortal"]) return MSIDCompanyPortalSsoProvider; + if ([deviceModeString isEqualToString:@"macBroker"]) return MSIDMacBrokerSsoProvider; + + return MSIDUnknownSsoProvider; +} + @end diff --git a/IdentityCore/tests/MSIDBrokerNativeAppOperationResponseTests.m b/IdentityCore/tests/MSIDBrokerNativeAppOperationResponseTests.m index f747b18d8..40b40febf 100644 --- a/IdentityCore/tests/MSIDBrokerNativeAppOperationResponseTests.m +++ b/IdentityCore/tests/MSIDBrokerNativeAppOperationResponseTests.m @@ -83,7 +83,8 @@ - (void)testJsonDictionary_whenAllPropertiesSet_shouldReturnJson NSDictionary *json = [response jsonDictionary]; #if TARGET_OS_OSX - XCTAssertEqual(11, json.allKeys.count); + XCTAssertEqual(12, json.allKeys.count); + XCTAssertEqualObjects(json[MSID_SSO_PROVIDER_TYPE_KEY], @"unknown"); #else XCTAssertEqual(10, json.allKeys.count); #endif diff --git a/IdentityCore/tests/MSIDBrokerOperationGetPasskeyAssertionResponseTests.m b/IdentityCore/tests/MSIDBrokerOperationGetPasskeyAssertionResponseTests.m index 846fa5939..cea8be784 100644 --- a/IdentityCore/tests/MSIDBrokerOperationGetPasskeyAssertionResponseTests.m +++ b/IdentityCore/tests/MSIDBrokerOperationGetPasskeyAssertionResponseTests.m @@ -178,7 +178,8 @@ - (void)testJsonDictionary_whenInitWithDictionary_shouldBeConvertedBackToDiction @"wpj_status": @"notJoined", @"preferred_auth_config": @"preferredAuthNotConfigured", #if TARGET_OS_OSX - @"platform_sso_status": @"platformSSONotEnabled" + @"platform_sso_status": @"platformSSONotEnabled", + @"sso_provider_type": @"unknown" #endif }; diff --git a/IdentityCore/tests/MSIDBrokerOperationGetPasskeyCredentialResponseTests.m b/IdentityCore/tests/MSIDBrokerOperationGetPasskeyCredentialResponseTests.m index c7defc324..d938cf81b 100644 --- a/IdentityCore/tests/MSIDBrokerOperationGetPasskeyCredentialResponseTests.m +++ b/IdentityCore/tests/MSIDBrokerOperationGetPasskeyCredentialResponseTests.m @@ -177,7 +177,8 @@ - (void)testJsonDictionary_whenInitWithDictionary_shouldBeConvertedBackToDiction @"wpj_status": @"notJoined", @"preferred_auth_config": @"preferredAuthNotConfigured", #if TARGET_OS_OSX - @"platform_sso_status": @"platformSSONotEnabled" + @"platform_sso_status": @"platformSSONotEnabled", + @"sso_provider_type": @"unknown" #endif }; diff --git a/IdentityCore/tests/MSIDBrokerOperationResponseTests.m b/IdentityCore/tests/MSIDBrokerOperationResponseTests.m index 153e9249b..0bb651e71 100644 --- a/IdentityCore/tests/MSIDBrokerOperationResponseTests.m +++ b/IdentityCore/tests/MSIDBrokerOperationResponseTests.m @@ -66,11 +66,12 @@ - (void)testJsonDictionary_whenAllPropertiesSet_shouldReturnJson response.operation = @"login"; response.success = true; response.clientAppVersion = @"1.0"; - response.deviceInfo = [[MSIDDeviceInfo alloc] initWithDeviceMode:MSIDDeviceModeShared ssoExtensionMode:MSIDSSOExtensionModeSilentOnly isWorkPlaceJoined:YES brokerVersion:@"1.2.3"]; + response.deviceInfo = [[MSIDDeviceInfo alloc] initWithDeviceMode:MSIDDeviceModeShared ssoExtensionMode:MSIDSSOExtensionModeSilentOnly isWorkPlaceJoined:YES brokerVersion:@"1.2.3" ssoProviderType:MSIDCompanyPortalSsoProvider]; NSDictionary *json = [response jsonDictionary]; #if TARGET_OS_OSX - XCTAssertEqual(10, json.allKeys.count); + XCTAssertEqual(11, json.allKeys.count); + XCTAssertEqualObjects(json[MSID_SSO_PROVIDER_TYPE_KEY], @"companyPortal"); #else XCTAssertEqual(9, json.allKeys.count); #endif @@ -93,7 +94,8 @@ - (void)testJsonDictionary_whenRequiredPropertiesSet_shouldReturnJson NSDictionary *json = [response jsonDictionary]; #if TARGET_OS_OSX - XCTAssertEqual(8, json.allKeys.count); + XCTAssertEqual(9, json.allKeys.count); + XCTAssertEqualObjects(json[MSID_SSO_PROVIDER_TYPE_KEY], @"unknown"); #else XCTAssertEqual(7, json.allKeys.count); #endif diff --git a/IdentityCore/tests/MSIDBrokerOperationTokenResponseTests.m b/IdentityCore/tests/MSIDBrokerOperationTokenResponseTests.m index fd86c74ef..20ffd7541 100644 --- a/IdentityCore/tests/MSIDBrokerOperationTokenResponseTests.m +++ b/IdentityCore/tests/MSIDBrokerOperationTokenResponseTests.m @@ -51,6 +51,7 @@ - (void)testJsonDictionary_whenAllPropertiesSetForSuccessResponse_shouldReturnJs tokenResponse.idToken = [MSIDTestIdTokenUtil idTokenWithPreferredUsername:DEFAULT_TEST_ID_TOKEN_USERNAME subject:DEFAULT_TEST_ID_TOKEN_SUBJECT]; __auto_type response = [[MSIDBrokerOperationTokenResponse alloc] initWithDeviceInfo:[MSIDDeviceInfo new]]; + response.deviceInfo.ssoProviderType = MSIDMacBrokerSsoProvider;; response.operation = @"login"; response.success = true; response.clientAppVersion = @"1.0"; @@ -61,7 +62,8 @@ - (void)testJsonDictionary_whenAllPropertiesSetForSuccessResponse_shouldReturnJs NSDictionary *json = [response jsonDictionary]; #if TARGET_OS_OSX - XCTAssertEqual(22, json.allKeys.count); + XCTAssertEqual(23, json.allKeys.count); + XCTAssertEqualObjects(json[@"sso_provider_type"], @"macBroker"); #else XCTAssertEqual(21, json.allKeys.count); #endif @@ -108,7 +110,7 @@ - (void)testJsonDictionary_whenNoAdditionalTokenResponseForSuccessResponse_shoul NSDictionary *json = [response jsonDictionary]; #if TARGET_OS_OSX - XCTAssertEqual(21, json.allKeys.count); + XCTAssertEqual(22, json.allKeys.count); #else XCTAssertEqual(20, json.allKeys.count); #endif @@ -181,7 +183,7 @@ - (void)testJsonDictionary_whenNoAuthorityForFailureResponse_shouldReturnJson NSDictionary *json = [response jsonDictionary]; #if TARGET_OS_OSX - XCTAssertEqual(21, json.allKeys.count); + XCTAssertEqual(22, json.allKeys.count); #else XCTAssertEqual(20, json.allKeys.count); #endif @@ -222,7 +224,7 @@ - (void)testJsonDictionary_whenNoAdditionalTokenResponseForFailureResponse_shoul NSDictionary *json = [response jsonDictionary]; #if TARGET_OS_OSX - XCTAssertEqual(20, json.allKeys.count); + XCTAssertEqual(21, json.allKeys.count); #else XCTAssertEqual(19, json.allKeys.count); #endif diff --git a/IdentityCore/tests/MSIDDeviceInfoTests.m b/IdentityCore/tests/MSIDDeviceInfoTests.m index 6b0edc770..2fc573dbb 100644 --- a/IdentityCore/tests/MSIDDeviceInfoTests.m +++ b/IdentityCore/tests/MSIDDeviceInfoTests.m @@ -249,7 +249,8 @@ - (void)testJsonDictionary_whenDeserialize_shouldGenerateCorrectJson { MSID_BROKER_BROKER_VERSION_KEY : @"1.2.3", MSID_PLATFORM_SSO_STATUS_KEY : @"platformSSONotEnabled", MSID_ADDITIONAL_EXTENSION_DATA_KEY: @"{\"dict\":{\"key\":\"value\"},\"feature_flag1\":1,\"token\":\"\"}", - MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY : @"preferredAuthNotConfigured" + MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY : @"preferredAuthNotConfigured", + MSID_SSO_PROVIDER_TYPE_KEY : @"unknown" }; #else NSDictionary *expectedJson = @{ @@ -284,7 +285,8 @@ - (void)testJsonDictionaryFromOldSDK_whenDeserialize_shouldGenerateCorrectJson { MSID_BROKER_BROKER_VERSION_KEY : @"1.2.3", MSID_PLATFORM_SSO_STATUS_KEY : @"platformSSONotEnabled", MSID_ADDITIONAL_EXTENSION_DATA_KEY: @"{\"dict\":{\"key\":\"value\"},\"feature_flag1\":1,\"token\":\"\"}", - MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY : @"preferredAuthNotConfigured" + MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY : @"preferredAuthNotConfigured", + MSID_SSO_PROVIDER_TYPE_KEY : @"unknown" }; #else NSDictionary *expectedJson = @{ @@ -332,6 +334,7 @@ - (void)testJsonDictionaryWithPlatformSSOStatus_whenDeserialize_shouldGenerateCo deviceInfo.wpjStatus = MSIDWorkPlaceJoinStatusJoined; deviceInfo.brokerVersion = @"1.2.3"; deviceInfo.platformSSOStatus = MSIDPlatformSSOEnabledAndRegistered; + deviceInfo.ssoProviderType = MSIDMacBrokerSsoProvider; NSDictionary *additionalData = @{@"feature_flag1":@1,@"token":@"",@"dict":@{@"key":@"value"}}; deviceInfo.additionalExtensionData = additionalData; @@ -344,7 +347,35 @@ - (void)testJsonDictionaryWithPlatformSSOStatus_whenDeserialize_shouldGenerateCo MSID_PLATFORM_SSO_STATUS_KEY : @"platformSSOEnabledAndRegistered", MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY : @"preferredAuthNotConfigured", - MSID_ADDITIONAL_EXTENSION_DATA_KEY: @"{\"dict\":{\"key\":\"value\"},\"feature_flag1\":1,\"token\":\"\"}" + MSID_ADDITIONAL_EXTENSION_DATA_KEY: @"{\"dict\":{\"key\":\"value\"},\"feature_flag1\":1,\"token\":\"\"}", + MSID_SSO_PROVIDER_TYPE_KEY : @"macBroker", + }; + + XCTAssertEqualObjects(expectedJson, [deviceInfo jsonDictionary]); +} + +- (void)testJsonDictionaryWithCompanyPortalAsSsoProvider_whenDeserialize_shouldGenerateCorrectJson +{ + MSIDDeviceInfo *deviceInfo = [MSIDDeviceInfo new]; + deviceInfo.deviceMode = MSIDDeviceModePersonal; + deviceInfo.wpjStatus = MSIDWorkPlaceJoinStatusJoined; + deviceInfo.brokerVersion = @"1.2.3"; + deviceInfo.platformSSOStatus = MSIDPlatformSSOEnabledAndRegistered; + deviceInfo.ssoProviderType = MSIDCompanyPortalSsoProvider; + + NSDictionary *additionalData = @{@"feature_flag1":@1,@"token":@"",@"dict":@{@"key":@"value"}}; + deviceInfo.additionalExtensionData = additionalData; + + NSDictionary *expectedJson = @{ + MSID_BROKER_DEVICE_MODE_KEY : @"personal", + MSID_BROKER_SSO_EXTENSION_MODE_KEY : @"full", + MSID_BROKER_WPJ_STATUS_KEY : @"joined", + MSID_BROKER_BROKER_VERSION_KEY : @"1.2.3", + MSID_PLATFORM_SSO_STATUS_KEY : + @"platformSSOEnabledAndRegistered", + MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY : @"preferredAuthNotConfigured", + MSID_ADDITIONAL_EXTENSION_DATA_KEY: @"{\"dict\":{\"key\":\"value\"},\"feature_flag1\":1,\"token\":\"\"}", + MSID_SSO_PROVIDER_TYPE_KEY : @"companyPortal", }; XCTAssertEqualObjects(expectedJson, [deviceInfo jsonDictionary]);