Skip to content

Commit dda457a

Browse files
committed
Add feature flags provider to be controlled from broker
1 parent ea6ed86 commit dda457a

File tree

12 files changed

+163
-0
lines changed

12 files changed

+163
-0
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,9 @@
17971797
B443F0002AD6327700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = B443EFFF2AD6327700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.h */; };
17981798
B443F0022AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B443F0012AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m */; };
17991799
B443F0032AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B443F0012AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m */; };
1800+
B48FC02F2D726A52007B80DB /* MSIDBrokerFlightProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = B48FC02E2D726A48007B80DB /* MSIDBrokerFlightProvider.h */; };
1801+
B48FC0312D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */; };
1802+
B48FC0322D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */; };
18001803
B49323912AD491C600E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = B493238F2AD4919400E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.h */; };
18011804
B49323922AD491CE00E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B49323902AD491B900E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m */; };
18021805
B49323932AD491CF00E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B49323902AD491B900E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m */; };
@@ -3243,6 +3246,8 @@
32433246
B443EFFC2AD6307E00782168 /* MSIDBrokerOperationGetPasskeyCredentialResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationGetPasskeyCredentialResponse.m; sourceTree = "<group>"; };
32443247
B443EFFF2AD6327700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerOperationPasskeyCredentialRequest.h; sourceTree = "<group>"; };
32453248
B443F0012AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationPasskeyCredentialRequest.m; sourceTree = "<group>"; };
3249+
B48FC02E2D726A48007B80DB /* MSIDBrokerFlightProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerFlightProvider.h; sourceTree = "<group>"; };
3250+
B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerFlightProvider.m; sourceTree = "<group>"; };
32463251
B493238F2AD4919400E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerOperationPasskeyAssertionRequest.h; sourceTree = "<group>"; };
32473252
B49323902AD491B900E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationPasskeyAssertionRequest.m; sourceTree = "<group>"; };
32483253
B49323942AD4DA0200E0CBC0 /* MSIDBrokerOperationGetPasskeyAssertionResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerOperationGetPasskeyAssertionResponse.h; sourceTree = "<group>"; };
@@ -5534,6 +5539,8 @@
55345539
728209CB26FE951900B5F018 /* MSIDJwtAlgorithm.h */,
55355540
237F8F2C2D5166FE0095F164 /* MSIDFlightManager.h */,
55365541
237F8F2D2D5166FE0095F164 /* MSIDFlightManager.m */,
5542+
B48FC02E2D726A48007B80DB /* MSIDBrokerFlightProvider.h */,
5543+
B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */,
55375544
);
55385545
path = src;
55395546
sourceTree = "<group>";
@@ -5976,6 +5983,7 @@
59765983
B2C707FD2192530E00D917B8 /* MSIDDefaultSilentTokenRequest.h in Headers */,
59775984
1EE541402458B30300A86414 /* MSIDDevicePopManager.h in Headers */,
59785985
E656E07D2C2627FB0011FB23 /* MSIDWebUpgradeRegResponse.h in Headers */,
5986+
B48FC02F2D726A52007B80DB /* MSIDBrokerFlightProvider.h in Headers */,
59795987
B286B9B32389DD78007833AD /* MSIDWebAADAuthCodeResponse.h in Headers */,
59805988
886F516E29CCA83000F09471 /* MSIDCIAMAuthorityResolver.h in Headers */,
59815989
B286B9D22389DF19007833AD /* MSIDAadAuthorityCache.h in Headers */,
@@ -7254,6 +7262,7 @@
72547262
600D19982095988C0004CD43 /* MSIDChallengeHandler.m in Sources */,
72557263
B26CEB042367B3B9009E6E54 /* MSIDSystemWebViewControllerFactory.m in Sources */,
72567264
609E74BE228CA5CA005E3FED /* MSIDAccountMetadataCacheAccessor.m in Sources */,
7265+
B48FC0312D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */,
72577266
23B018C42356D51200207FEC /* NSDictionary+MSIDQueryItems.m in Sources */,
72587267
2394F2042D4894FF00E44F6E /* MSIDWebUpgradeRegOperation.m in Sources */,
72597268
B2C708AE219A612A00D917B8 /* MSIDDefaultBrokerTokenRequest.m in Sources */,
@@ -8072,6 +8081,7 @@
80728081
96235F96207D7286007EAB36 /* MSIDWebOAuth2AuthCodeResponse.m in Sources */,
80738082
B239A43D209E8170000A3268 /* MSIDAccountCredentialCache.m in Sources */,
80748083
23B018822355481800207FEC /* MSIDSSOExtensionInteractiveTokenRequest.m in Sources */,
8084+
B48FC0322D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */,
80758085
239E8F88233D951D00251373 /* MSIDBrokerOperationTokenResponse.m in Sources */,
80768086
B208854A29ADB86200A50B88 /* MSIDExternalSSOContextMock.m in Sources */,
80778087
B2B1D57320425DFD00DD81F0 /* MSIDAccountCacheItem.m in Sources */,

IdentityCore/src/MSIDBrokerConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ extern NSString * _Nonnull const MSID_SKIP_VALIDATE_RESULT_ACCOUNT_KEY;
9696
extern NSString * _Nonnull const MSID_JIT_TROUBLESHOOTING_HOST;
9797
extern NSString * _Nonnull const MSID_IS_CALLER_MANAGED_KEY;
9898
extern NSString * _Nonnull const MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY;
99+
extern NSString * _Nonnull const MSID_BROKER_CLIENT_FLIGHTS_KEY;
99100
extern NSString * _Nonnull const MSID_BROKER_SDM_WPJ_ATTEMPTED;
100101
extern NSString * _Nonnull const MSID_EXP_RETRY_ON_NETWORK;
101102
extern NSString * _Nonnull const MSID_EXP_ENABLE_CONNECTION_CLOSE;

IdentityCore/src/MSIDBrokerConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
NSString *const MSID_BROKER_TYPES_OF_HEADER = @"types_of_header";
7878
NSString *const MSID_BROKER_REQUEST_SENT_TIMESTAMP = @"request_sent_timestamp";
7979
NSString *const MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY = @"preferred_auth_config";
80+
NSString *const MSID_BROKER_CLIENT_FLIGHTS_KEY = @"client_flights";
8081
NSString *const MSID_BROKER_ACCOUNT_HOME_TENANT_ID = @"account_home_tenant_id";
8182
NSString *const MSID_CLIENT_SKU_KEY = @"client_sku";
8283
NSString *const MSID_SKIP_VALIDATE_RESULT_ACCOUNT_KEY = @"skip_validate_result_account";
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
//
3+
// Copyright (c) Microsoft Corporation.
4+
// All rights reserved.
5+
//
6+
// This code is licensed under the MIT License.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files(the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions :
14+
//
15+
// The above copyright notice and this permission notice shall be included in
16+
// all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
// THE SOFTWARE.
25+
26+
#import <Foundation/Foundation.h>
27+
#import "MSIDFlightManager.h"
28+
29+
NS_ASSUME_NONNULL_BEGIN
30+
31+
@interface MSIDBrokerFlightProvider : NSObject <MSIDFlightManagerInterface>
32+
33+
- (instancetype)initWithBase64EncodedFlightsPayload:(nullable NSString *)base64EncodedFlightsPayload;
34+
35+
- (instancetype _Nullable )init NS_UNAVAILABLE;
36+
+ (instancetype _Nullable )new NS_UNAVAILABLE;
37+
38+
@end
39+
40+
NS_ASSUME_NONNULL_END
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// Copyright (c) Microsoft Corporation.
3+
// All rights reserved.
4+
//
5+
// This code is licensed under the MIT License.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files(the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions :
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
#import "MSIDBrokerFlightProvider.h"
26+
#import "NSJSONSerialization+MSIDExtensions.h"
27+
28+
@interface MSIDBrokerFlightProvider()
29+
30+
@property (nonatomic, nullable) NSDictionary *clientFlightsPayload;
31+
32+
@end
33+
34+
@implementation MSIDBrokerFlightProvider
35+
36+
- (instancetype)initWithBase64EncodedFlightsPayload:(nullable NSString *)base64EncodedFlightsPayload
37+
{
38+
self = [super init];
39+
40+
if (self)
41+
{
42+
if ([NSString msidIsStringNilOrBlank:base64EncodedFlightsPayload])
43+
{
44+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo,nil, @"Broker client flights is nil or empty");
45+
return nil;
46+
}
47+
48+
NSDictionary *clientFlightsDict = nil;
49+
50+
NSData *decodedJsonData = [[base64EncodedFlightsPayload msidBase64UrlDecode] dataUsingEncoding:NSUTF8StringEncoding];
51+
if (decodedJsonData && [decodedJsonData length])
52+
{
53+
clientFlightsDict = [NSJSONSerialization msidNormalizedDictionaryFromJsonData:decodedJsonData error:nil];
54+
55+
if (![clientFlightsDict isKindOfClass:[NSDictionary class]])
56+
{
57+
MSID_LOG_WITH_CTX(MSIDLogLevelWarning,nil, @"Invalid broker client flight format");
58+
return nil;
59+
}
60+
}
61+
else
62+
{
63+
MSID_LOG_WITH_CTX(MSIDLogLevelWarning,nil, @"Failed to decode base64encoded client flights from broker");
64+
return nil;
65+
}
66+
67+
if (clientFlightsDict)
68+
{
69+
self.clientFlightsPayload = clientFlightsDict;
70+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, nil, @"Client flights from broker is decoded successfully");
71+
}
72+
}
73+
74+
return self;
75+
}
76+
77+
#pragma mark - MSIDFlightManagerInterface
78+
79+
- (BOOL)boolForKey:(nonnull NSString *)flightKey
80+
{
81+
if (self.clientFlightsPayload)
82+
{
83+
return [self.clientFlightsPayload[flightKey] boolValue];
84+
}
85+
86+
return NO;
87+
}
88+
89+
@end

IdentityCore/src/MSIDConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,6 @@ extern NSString * _Nonnull const MSID_BROWSER_RESPONSE_SWITCH_BROWSER_RESUME;
176176

177177
extern NSString * _Nonnull const MSID_FLIGHT_USE_V2_WEB_RESPONSE_FACTORY;
178178
extern NSString * _Nonnull const MSID_FLIGHT_SUPPORT_DUNA_CBA;
179+
extern NSString * _Nonnull const MSID_FLIGHT_ENABLE_CLIENT_SINGLE_FAMILY_REFRESH_TOKEN;
179180

180181
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]

IdentityCore/src/MSIDConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878

7979
NSString *const MSID_FLIGHT_USE_V2_WEB_RESPONSE_FACTORY = @"use_v2_web_response_factory";
8080
NSString *const MSID_FLIGHT_SUPPORT_DUNA_CBA = @"support_duna_cba";
81+
NSString *const MSID_FLIGHT_ENABLE_CLIENT_SINGLE_FAMILY_REFRESH_TOKEN = @"enable_client_single_family_refresh_token";
8182

8283

8384
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]

IdentityCore/src/broker_operation/response/MSIDDeviceInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
6666
@property (nonatomic, nullable) NSString *brokerVersion;
6767
@property (nonatomic) NSDictionary *additionalExtensionData;
6868
@property (nonatomic) MSIDPreferredAuthMethod preferredAuthConfig;
69+
@property (nonatomic) NSString *clientFlights;
6970

7071
#if TARGET_OS_OSX
7172
@property (nonatomic) MSIDPlatformSSOStatus platformSSOStatus;

IdentityCore/src/broker_operation/response/MSIDDeviceInfo.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ - (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(__unused NSEr
6363
_wpjStatus = [self wpjStatusEnumFromString:[json msidStringObjectForKey:MSID_BROKER_WPJ_STATUS_KEY]];
6464
_brokerVersion = [json msidStringObjectForKey:MSID_BROKER_BROKER_VERSION_KEY];
6565
_preferredAuthConfig = [self preferredAuthConfigurationEnumFromString:[json msidStringObjectForKey:MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY]];
66+
_clientFlights = [json msidStringObjectForKey:MSID_BROKER_CLIENT_FLIGHTS_KEY];
6667

6768
#if TARGET_OS_OSX
6869
_platformSSOStatus = [self platformSSOStatusEnumFromString:[json msidStringObjectForKey:MSID_PLATFORM_SSO_STATUS_KEY]];
@@ -95,6 +96,7 @@ - (NSDictionary *)jsonDictionary
9596
json[MSID_BROKER_WPJ_STATUS_KEY] = [self wpjStatusStringFromEnum:self.wpjStatus];
9697
json[MSID_BROKER_BROKER_VERSION_KEY] = self.brokerVersion;
9798
json[MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY] = [self preferredAuthConfigurationStringFromEnum:self.preferredAuthConfig];
99+
json[MSID_BROKER_CLIENT_FLIGHTS_KEY] = self.clientFlights;
98100
#if TARGET_OS_OSX
99101
json[MSID_PLATFORM_SSO_STATUS_KEY] = [self platformSSOStatusStringFromEnum:self.platformSSOStatus];
100102
#endif

IdentityCore/src/oauth2/MSIDBrokerResponse.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
@property (readonly) NSString *errorDomain;
4444
@property (readonly) NSString *target;
4545

46+
// Client flights managed by broker, base64 encoded
47+
@property (readonly) NSString *clientFlights;
48+
4649
// Derived properties
4750
@property (readonly) MSIDTokenResponse *tokenResponse;
4851
@property (readonly) MSIDAuthority *msidAuthority;

0 commit comments

Comments
 (0)