Skip to content

Commit 7335d18

Browse files
antrix1989hieunguyenmsftPeter LeePeter LeeNerevarineRule
authored
Release 1.6.3 (#966)
* POC for Olga's suggestion * initialize commit * throttling service core functions * update last refresh time function * hook up throttling in silent request * update invoke point for UI Throttle * refactor code. invoke sso-ext flow * refactor * update SSO-ext flow * update file location * update metadata cache. Address some comments * refactor code: move throttling type handler to helper class. add more utiliti class * refactor code to using factory pattern. Move the business handle code from service to Model class * clean code * fix error when e2e test. Address some comment. Clean some unused class * initial commit * first sample unit test :) * new UT * changelog * fixed unsigned int in MSIDThrottlingModelInteractionRequire * ... * .. * travis silly unsigned error * Address comments * address comment * update Peter comments * address comments * update last refresh time when interactive flow is success * update thumbprint log * ... * gosh * ... * ... * fix UT * Handle missing bundle identifier when writing wipe data to keychain * nonSSO serverside test * address comment. update sso interactive flow. * intermi save * added more unit tests * throtting service integration test * demiurge * throttling test * update from accessgroup to datasource * saving * yaldabaoth * ... * ... * monad * resolved unit test failure due to swizzling/category method for default cache accessor * reverting unnecessary changes * solved concurrency issue * heroic * enhanced logging * changelog * add unit tests * Remove input param to make the method reusable in CPP, added tests (#956) * Remove input param to make the method reusable in CPP, added tests * try fix UT * add and change some parameters * clean up the format * update * clean up files * fix ascii error when reporting build in terminal * fix swizzle causing test cases failing * fix swizzle * added PII masking * address comments * add extended token cache into interactive token request, remove casting in local intereactive controller * merge with dev * add extended token cache in sso ext silent token request * update back code * remove class check * added additional logging * Throttling merge to dev (#960) * throttling feature. * update at pop logic * update changelog * Minor logging improvements * addressed comments * Initial Commit * Removed unnecessary change * Changelog * Update changelog. * Update release branch (#968) * Added checking for the existence of id_token when validating response * Skip validate token result for id_token only case * Fixed compile error * Skip save access token * Adding test case * Addressed comments * Fixed build issue * Modify init method for keychain token cache so that developers can se… (#965) * Address commits from previous PR (#967) Co-authored-by: Tatsuro Shibamura <me@shibayan.jp> Co-authored-by: Olga Dalton <oldalton@microsoft.com> Co-authored-by: kaisong1990 <kaisong1990@gmail.com> Co-authored-by: Hieu Nguyen <65981263+hieunguyenmsft@users.noreply.github.com> Co-authored-by: Peter Lee <peterlee@ELSMITH2-X1G2.northamerica.corp.microsoft.com> Co-authored-by: HieuNguyen <hiengu@microsoft.com> Co-authored-by: Peter Lee <peterlee@Peters-MacBook-Pro.local> Co-authored-by: Peter Lee <30302999+NerevarineRule@users.noreply.github.com> Co-authored-by: Olga Dalton <oldalton@microsoft.com> Co-authored-by: Peter Lee <peterlee@MININT-947M1BJ.redmond.corp.microsoft.com> Co-authored-by: Peter Lee <peterlee@CBREV-LOOGUN.northamerica.corp.microsoft.com> Co-authored-by: Yong Zeng <zeyong@microsoft.com> Co-authored-by: kaisong1990 <kaisong1990@gmail.com> Co-authored-by: tongyuze <yuto@microsoft.com> Co-authored-by: Logan Dorsey <> Co-authored-by: Logan Dorsey <logdog16@users.noreply.github.com> Co-authored-by: Tatsuro Shibamura <me@shibayan.jp>
1 parent 9e0af0b commit 7335d18

File tree

89 files changed

+4314
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+4314
-272
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 128 additions & 2 deletions
Large diffs are not rendered by default.

IdentityCore/src/MSIDConstants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ extern NSString * _Nonnull const MSID_CLIENT_SDK_TYPE_ADAL;
124124

125125
extern NSString * _Nonnull const MSID_POP_TOKEN_PRIVATE_KEY;
126126
extern NSString * _Nonnull const MSID_POP_TOKEN_KEY_LABEL;
127+
128+
extern NSString * _Nonnull const MSID_THROTTLING_METADATA_KEYCHAIN;
129+
extern NSString * _Nonnull const MSID_THROTTLING_METADATA_KEYCHAIN_VERSION;

IdentityCore/src/MSIDConstants.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@
5555

5656
NSString *const MSID_POP_TOKEN_PRIVATE_KEY = @"com.microsoft.token.private.key";
5757
NSString *const MSID_POP_TOKEN_KEY_LABEL = @"com.microsoft.token.key";
58+
NSString *const MSID_THROTTLING_METADATA_KEYCHAIN = @"com.microsoft.identity.throttling.metadata";
59+
NSString *const MSID_THROTTLING_METADATA_KEYCHAIN_VERSION = @"Ver1";

IdentityCore/src/MSIDOAuth2Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ extern NSString *const MSID_CLIENT_INFO_CACHE_KEY;
107107
extern NSString *const MSID_ID_TOKEN_CACHE_KEY;
108108
extern NSString *const MSID_ADDITIONAL_INFO_CACHE_KEY;
109109
extern NSString *const MSID_EXPIRES_ON_CACHE_KEY;
110+
extern NSString *const MSID_REFRESH_ON_CACHE_KEY;
110111
extern NSString *const MSID_OAUTH_TOKEN_TYPE_CACHE_KEY;
111112
extern NSString *const MSID_CACHED_AT_CACHE_KEY;
112113
extern NSString *const MSID_EXTENDED_EXPIRES_ON_CACHE_KEY;

IdentityCore/src/MSIDOAuth2Constants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
NSString *const MSID_ID_TOKEN_CACHE_KEY = @"id_token";
110110
NSString *const MSID_ADDITIONAL_INFO_CACHE_KEY = @"additional_info";
111111
NSString *const MSID_EXPIRES_ON_CACHE_KEY = @"expires_on";
112+
NSString *const MSID_REFRESH_ON_CACHE_KEY = @"refresh_on";
112113
NSString *const MSID_OAUTH_TOKEN_TYPE_CACHE_KEY = @"access_token_type";
113114
NSString *const MSID_CACHED_AT_CACHE_KEY = @"cached_at";
114115
NSString *const MSID_EXTENDED_EXPIRES_ON_CACHE_KEY = @"extended_expires_on";

IdentityCore/src/broker_operation/request/silent_token_request/MSIDBrokerOperationSilentTokenRequest.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ + (NSSet *)fullRequestThumbprintExcludeParams
129129
MSID_BROKER_CLIENT_VERSION_KEY,
130130
MSID_BROKER_CLIENT_APP_VERSION_KEY,
131131
MSID_BROKER_CLIENT_APP_NAME_KEY,
132-
MSID_BROKER_CORRELATION_ID_KEY]];
132+
MSID_BROKER_CORRELATION_ID_KEY,
133+
MSID_BROKER_KEY]];
133134
});
134135
return excludeSet;
135136

@@ -147,5 +148,6 @@ + (NSSet *)strictRequestThumbprintIncludeParams
147148

148149
}
149150

151+
150152
@end
151153
#endif

IdentityCore/src/cache/MSIDKeychainTokenCache.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,14 @@ - (BOOL)removeItemsWithKey:(MSIDCacheKey *)key
562562
- (BOOL)saveWipeInfoWithContext:(id<MSIDRequestContext>)context
563563
error:(NSError **)error
564564
{
565-
NSDictionary *wipeInfo = @{ @"bundleId" : [[NSBundle mainBundle] bundleIdentifier],
565+
NSString *appIdentifier = [[NSBundle mainBundle] bundleIdentifier];
566+
567+
if (!appIdentifier)
568+
{
569+
appIdentifier = [NSProcessInfo processInfo].processName;
570+
}
571+
572+
NSDictionary *wipeInfo = @{ @"bundleId" : appIdentifier ?: @"",
566573
@"wipeTime" : [NSDate date]
567574
};
568575

IdentityCore/src/cache/accessor/MSIDAccountCredentialCache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#import <Foundation/Foundation.h>
2525
#import "MSIDCredentialType.h"
2626
#import "MSIDAccountType.h"
27+
#import "MSIDExtendedTokenCacheDataSource.h"
2728

2829
@class MSIDAccountCacheItem;
2930
@class MSIDAppMetadataCacheItem;
@@ -38,6 +39,8 @@
3839

3940
@interface MSIDAccountCredentialCache : NSObject
4041

42+
@property (nonatomic, readonly) id<MSIDExtendedTokenCacheDataSource> _Nonnull dataSource;
43+
4144
- (nonnull instancetype)initWithDataSource:(nonnull id<MSIDExtendedTokenCacheDataSource>)dataSource;
4245

4346
/*

IdentityCore/src/cache/accessor/MSIDAccountCredentialCache.m

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
@interface MSIDAccountCredentialCache()
4141
{
42-
id<MSIDExtendedTokenCacheDataSource> _dataSource;
4342
MSIDCacheItemJsonSerializer *_serializer;
4443
}
4544

@@ -69,13 +68,16 @@ - (instancetype)initWithDataSource:(id<MSIDExtendedTokenCacheDataSource>)dataSou
6968
context:(nullable id<MSIDRequestContext>)context
7069
error:(NSError * _Nullable * _Nullable)error
7170
{
71+
NSString *className = NSStringFromClass(self.class);
72+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"(%@) retrieving cached credentials using credential query", className);
7273
NSError *cacheError = nil;
73-
74+
7475
NSArray<MSIDCredentialCacheItem *> *results = [_dataSource tokensWithKey:cacheQuery
7576
serializer:_serializer
7677
context:context
7778
error:&cacheError];
7879

80+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"(%@) retrieved %ld cached credentials", className, (long)results.count);
7981
if (cacheError)
8082
{
8183
if (error)
@@ -91,14 +93,16 @@ - (instancetype)initWithDataSource:(id<MSIDExtendedTokenCacheDataSource>)dataSou
9193
BOOL shouldMatchAccount = !cacheQuery.homeAccountId || !cacheQuery.environment;
9294

9395
NSMutableArray *filteredResults = [NSMutableArray array];
94-
96+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"(%@) credential query requires exact match with the cached credential items. Performing additional filtering checks.", className);
9597
for (MSIDCredentialCacheItem *cacheItem in results)
9698
{
99+
MSID_LOG_WITH_CTX_PII(MSIDLogLevelVerbose, context, @"(%@) performing filtering check on cached credential item with the following properties - client ID: %@, target: %@, realm: %@, environment: %@, familyID: %@, homeAccountId: %@, enrollmentId: %@, appKey: %@, applicationIdentifier: %@, tokenType: %@", className, cacheItem.clientId, cacheItem.target, cacheItem.realm, cacheItem.environment, cacheItem.familyId, MSID_PII_LOG_TRACKABLE(cacheItem.homeAccountId), MSID_PII_LOG_MASKABLE(cacheItem.enrollmentId), MSID_PII_LOG_MASKABLE(cacheItem.appKey), MSID_EUII_ONLY_LOG_MASKABLE(cacheItem.applicationIdentifier), cacheItem.tokenType);
97100
if (shouldMatchAccount
98101
&& ![cacheItem matchesWithHomeAccountId:cacheQuery.homeAccountId
99102
environment:cacheQuery.environment
100103
environmentAliases:cacheQuery.environmentAliases])
101104
{
105+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"(%@) cached item had mismatching homeAccountID or environment/aliases with the credential query. excluding from the results.", className);
102106
continue;
103107
}
104108

@@ -110,15 +114,16 @@ - (instancetype)initWithDataSource:(id<MSIDExtendedTokenCacheDataSource>)dataSou
110114
targetMatching:cacheQuery.targetMatchingOptions
111115
clientIdMatching:cacheQuery.clientIdMatchingOptions])
112116
{
117+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"(%@) cached item had mismatching realm/clientId/familyId/target/requestedClaims with the credential query. excluding from the results.", className);
113118
continue;
114119
}
115-
120+
116121
[filteredResults addObject:cacheItem];
117122
}
118-
123+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"(%@) returning %ld filtered credentials", className, (long)filteredResults.count);
119124
return filteredResults;
120125
}
121-
126+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"(%@) returning %ld credentials", className, (long)results.count);
122127
return results;
123128
}
124129

IdentityCore/src/cache/accessor/MSIDDefaultTokenCacheAccessor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#import <Foundation/Foundation.h>
2525
#import "MSIDCacheAccessor.h"
26+
#import "MSIDAccountCredentialCache.h"
2627

2728
@class MSIDAccountIdentifier;
2829
@class MSIDConfiguration;
@@ -38,6 +39,8 @@
3839

3940
@interface MSIDDefaultTokenCacheAccessor : NSObject <MSIDCacheAccessor>
4041

42+
@property (nonatomic, readonly) MSIDAccountCredentialCache *accountCredentialCache;
43+
4144
- (instancetype)initWithDataSource:(id<MSIDExtendedTokenCacheDataSource>)dataSource
4245
otherCacheAccessors:(NSArray<id<MSIDCacheAccessor>> *)otherAccessors;
4346

0 commit comments

Comments
 (0)