Skip to content
2 changes: 1 addition & 1 deletion MSAL/IdentityCore
Submodule IdentityCore updated 32 files
+108 −0 .github/workflows/auto-retag.yml
+86 −0 IdentityCore/IdentityCore.xcodeproj/project.pbxproj
+8 −0 IdentityCore/src/MSIDConstants.h
+4 −0 IdentityCore/src/MSIDConstants.m
+27 −17 ...yCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetTokenRequest.m
+28 −3 IdentityCore/src/network/MSIDHttpRequest.m
+8 −0 IdentityCore/src/network/error_handler/MSIDAADRequestErrorHandler.m
+9 −0 IdentityCore/src/requests/MSIDSilentTokenRequest.m
+64 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlow.h
+151 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlow.m
+74 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowBlob.h
+94 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowBlob.m
+83 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowConstants.h
+85 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowConstants.m
+71 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowLogger.h
+163 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowLogger.m
+47 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowUtils.h
+83 −0 IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowUtils.m
+570 −0 IdentityCore/tests/MSIDExecutionFlowBlobTests.m
+39 −0 IdentityCore/tests/MSIDExecutionFlowLogger+Test.h
+951 −0 IdentityCore/tests/MSIDExecutionFlowLoggerTests.m
+112 −0 IdentityCore/tests/MSIDExecutionFlowTagTests.m
+690 −0 IdentityCore/tests/MSIDExecutionFlowTests.m
+2 −2 IdentityCore/tests/MSIDThrottlingServiceIntegrationTests.m
+2 −2 IdentityCore/tests/MSIDThumbprintCalculatorTests.m
+10 −1 IdentityCore/tests/integration/ios/MSIDDefaultSilentTokenRequestTests.m
+42 −158 azure_pipelines/broker_submodule_check.yml
+142 −0 azure_pipelines/broker_submodule_steps.yml
+2 −2 azure_pipelines/pr-validation.yml
+3 −3 build.py
+3 −0 changelog.txt
+177 −0 scripts/retag_untagged.py
82 changes: 46 additions & 36 deletions MSAL/test/app/ios/MSALTestAppAcquireTokenViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#import "MSIDAssymetricKeyKeychainGenerator.h"
#import "MSIDAssymetricKeyLookupAttributes.h"
#import "MSIDConstants.h"
#import "MSIDExecutionFlowLogger.h"

#define TEST_EMBEDDED_WEBVIEW_TYPE_INDEX 0
#define TEST_SYSTEM_WEBVIEW_TYPE_INDEX 1
Expand Down Expand Up @@ -248,6 +249,8 @@ - (MSALInteractiveTokenParameters *)tokenParams:(BOOL)isSSOSeedingCall

parameters.loginHint = self.loginHintTextField.text;
parameters.account = settings.currentAccount;
NSUUID *correlationId = [NSUUID UUID];
parameters.correlationId = correlationId;
parameters.promptType = isSSOSeedingCall ? MSALPromptTypeDefault : [self promptTypeValue];

parameters.extraQueryParameters = isSSOSeedingCall ? [NSDictionary msidDictionaryFromWWWFormURLEncodedString:@"prompt=none"] : [NSDictionary msidDictionaryFromWWWFormURLEncodedString:self.extraQueryParamsTextField.text];
Expand Down Expand Up @@ -328,7 +331,7 @@ - (void)acquireSSOSeeding

if (!result)
{
[self updateResultViewError:error];
[self updateResultViewError:error executionFlow:nil];
}
[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
Expand Down Expand Up @@ -392,41 +395,43 @@ - (IBAction)onAcquireTokenInteractiveButtonTapped:(__unused id)sender
{
return;
}


MSALInteractiveTokenParameters *params = [self tokenParams:NO];
[[MSIDExecutionFlowLogger sharedInstance] registerExecutionFlowWithCorrelationId:params.correlationId];
__block BOOL fBlockHit = NO;
void (^completionBlock)(MSALResult *result, NSError *error) = ^(MSALResult *result, NSError *error) {

if (fBlockHit)
{
[self showCompletionBlockHitMultipleTimesAlert];
return;
}

fBlockHit = YES;
dispatch_async(dispatch_get_main_queue(), ^{

if (result)
{
if ([MSALTestAppSettings isSSOSeeding])
[[MSIDExecutionFlowLogger sharedInstance] retrieveAndFlushExecutionFlowWithCorrelationId:params.correlationId queryKeys:nil completion:^(NSString * _Nullable executionFlow) {
dispatch_async(dispatch_get_main_queue(), ^{
if (result)
{
[self acquireSSOSeeding];
if ([MSALTestAppSettings isSSOSeeding])
{
[self acquireSSOSeeding];
}
else
{
[self updateResultView:result executionFlow:executionFlow];
[self hideCustomeWebViewIfNeed];
}
}
else
{
[self updateResultView:result];
[self updateResultViewError:error executionFlow:executionFlow];
[self hideCustomeWebViewIfNeed];
}
}
else
{
[self updateResultViewError:error];
[self hideCustomeWebViewIfNeed];
}
[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
}];
};

[application acquireTokenWithParameters:[self tokenParams:NO] completionBlock:completionBlock];
[application acquireTokenWithParameters:params completionBlock:completionBlock];
}

- (IBAction)onAcquireTokenSilentButtonTapped:(__unused id)sender
Expand Down Expand Up @@ -483,6 +488,9 @@ - (IBAction)onAcquireTokenSilentButtonTapped:(__unused id)sender
}

parameters.authority = settings.authority;
NSUUID *correlationId = [NSUUID UUID];
parameters.correlationId = correlationId;
[[MSIDExecutionFlowLogger sharedInstance] registerExecutionFlowWithCorrelationId:correlationId];
__block BOOL fBlockHit = NO;
self.acquireSilentButton.enabled = NO;
[application acquireTokenSilentWithParameters:parameters completionBlock:^(MSALResult *result, NSError *error)
Expand All @@ -494,18 +502,20 @@ - (IBAction)onAcquireTokenSilentButtonTapped:(__unused id)sender
}

fBlockHit = YES;
dispatch_async(dispatch_get_main_queue(), ^{
self.acquireSilentButton.enabled = YES;
if (result)
{
[self updateResultView:result];
}
else
{
[self updateResultViewError:error];
}
[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
[[MSIDExecutionFlowLogger sharedInstance] retrieveAndFlushExecutionFlowWithCorrelationId:correlationId queryKeys:nil completion:^(NSString * _Nullable executionFlow) {
dispatch_async(dispatch_get_main_queue(), ^{
self.acquireSilentButton.enabled = YES;
if (result)
{
[self updateResultView:result executionFlow:executionFlow];
}
else
{
[self updateResultViewError:error executionFlow:executionFlow];
}
[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
}];
}];
}

Expand Down Expand Up @@ -713,16 +723,16 @@ - (void)stopStressTest
MSALGlobalConfig.loggerConfig.logLevel = MSALLogLevelVerbose;
}

- (void)updateResultViewError:(NSError *)error
- (void)updateResultViewError:(NSError *)error executionFlow:(NSString *)executionFlow
{
NSString *resultText = [NSString stringWithFormat:@"%@", error];
NSString *resultText = [NSString stringWithFormat:@"%@\n executionFlow: %@", error, executionFlow];
[self.resultTextView setText:resultText];
}

- (void)updateResultView:(MSALResult *)result
- (void)updateResultView:(MSALResult *)result executionFlow:(NSString *)executionFlow
{
NSString *resultText = [NSString stringWithFormat:@"{\n\taccessToken = %@\n\texpiresOn = %@\n\ttenantId = %@\n\tuser = %@\n\tscopes = %@\n\tauthority = %@\n\tcorrelationId = %@\n}",
[result.accessToken msidTokenHash], result.expiresOn, result.tenantProfile.tenantId, result.account, result.scopes, result.authority,result.correlationId];
NSString *resultText = [NSString stringWithFormat:@"{\n\taccessToken = %@\n\texpiresOn = %@\n\ttenantId = %@\n\tuser = %@\n\tscopes = %@\n\tauthority = %@\n\tcorrelationId = %@\n} executionFlow: %@",
[result.accessToken msidTokenHash], result.expiresOn, result.tenantProfile.tenantId, result.account, result.scopes, result.authority,result.correlationId, executionFlow];

[self.resultTextView setText:resultText];

Expand Down
130 changes: 71 additions & 59 deletions MSAL/test/app/mac/MSALAcquireTokenViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#import "MSALAuthenticationSchemePop.h"
#import "MSALAuthenticationSchemeBearer.h"
#import "MSALAuthenticationSchemeProtocol.h"
#import "MSIDExecutionFlowLogger.h"

static NSString * const clientId = @"clientId";
static NSString * const redirectUri = @"redirectUri";
Expand Down Expand Up @@ -127,7 +128,7 @@ - (void)populateUsers
{
if (error)
{
[self updateResultViewError:error];
[self updateResultViewError:error executionFlow:nil];
return;
}

Expand Down Expand Up @@ -174,19 +175,19 @@ - (void)setScopes:(NSArray *)scopes
}
}

- (void)updateResultView:(MSALResult *)result
- (void)updateResultView:(MSALResult *)result executionFlow:(NSString *)executionFlow
{
NSString *resultText = [NSString stringWithFormat:@"{\n\taccessToken = %@\n\texpiresOn = %@\n\ttenantId = %@\n\tuser = %@\n\tscopes = %@\n\tauthority = %@\n\tcorrelationId = %@\n}",
[result.accessToken msidTokenHash], result.expiresOn, result.tenantProfile.tenantId, result.account, result.scopes, result.authority,result.correlationId];
NSString *resultText = [NSString stringWithFormat:@"{\n\taccessToken = %@\n\texpiresOn = %@\n\ttenantId = %@\n\tuser = %@\n\tscopes = %@\n\tauthority = %@\n\tcorrelationId = %@\n}\nexecutionFlow:%@",
[result.accessToken msidTokenHash], result.expiresOn, result.tenantProfile.tenantId, result.account, result.scopes, result.authority,result.correlationId, executionFlow];

[self.resultTextView setString:resultText];

NSLog(@"%@", resultText);
}

- (void)updateResultViewError:(NSError *)error
- (void)updateResultViewError:(NSError *)error executionFlow:(NSString *)executionFlow
{
NSString *resultText = [NSString stringWithFormat:@"%@", error];
NSString *resultText = [NSString stringWithFormat:@"%@\nexecutionFlow:%@", error, executionFlow];
[self.resultTextView setString:resultText];
NSLog(@"%@", resultText);
}
Expand Down Expand Up @@ -364,7 +365,7 @@ - (IBAction)wipeAllAccounts:(__unused id)sender
{
if (!success)
{
[self updateResultViewError:error];
[self updateResultViewError:error executionFlow:nil];
}
else
{
Expand Down Expand Up @@ -426,39 +427,40 @@ - (IBAction)acquireTokenInteractive:(id)sender
}

__block BOOL fBlockHit = NO;

NSUUID *correlationId = [NSUUID UUID];
void (^completionBlock)(MSALResult *result, NSError *error) = ^(MSALResult *result, NSError *error) {

if (fBlockHit)
{
[self showAlert:@"Error!" informativeText:@"Completion block was hit multiple times!"];
return;
}
fBlockHit = YES;

dispatch_async(dispatch_get_main_queue(), ^{
if (result)
{
if ([MSALTestAppSettings isSSOSeeding])
fBlockHit = YES;
[[MSIDExecutionFlowLogger sharedInstance] retrieveAndFlushExecutionFlowWithCorrelationId:correlationId queryKeys:nil completion:^(NSString * _Nullable executionFlow) {
dispatch_async(dispatch_get_main_queue(), ^{
if (result)
{
[self acquireSSOSeeding];
if ([MSALTestAppSettings isSSOSeeding])
{
[self acquireSSOSeeding];
}
else
{
[self updateResultView:result executionFlow:executionFlow];
[self populateUsers];
}
}
else
{
[self updateResultView:result];
[self populateUsers];
[self updateResultViewError:error executionFlow:executionFlow];
}
}
else
{
[self updateResultViewError:error];
}

[self.webView setHidden:YES];

[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});

[self.webView setHidden:YES];

[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
}];
};

MSALWebviewParameters *webviewParameters = [[MSALWebviewParameters alloc] initWithAuthPresentationViewController:self];
Expand All @@ -478,7 +480,8 @@ - (IBAction)acquireTokenInteractive:(id)sender
parameters.extraQueryParameters = extraQueryParameters;
parameters.authenticationScheme = [self authScheme];
parameters.msalXpcMode = [self xpcMode];

parameters.correlationId = correlationId;
[[MSIDExecutionFlowLogger sharedInstance] registerExecutionFlowWithCorrelationId:correlationId];
[application acquireTokenWithParameters:parameters completionBlock:completionBlock];
}

Expand All @@ -487,35 +490,40 @@ - (void)acquireSSOSeeding
NSError *error = nil;

MSALPublicClientApplication *application = [self createPublicClientApplication:&error SSOSeeding:YES];

NSUUID *correlationId = [NSUUID UUID];

if (!application)
{
return;
}

__block BOOL fBlockHit = NO;
void (^completionBlock)(MSALResult *result, NSError *error) = ^(MSALResult *result, NSError *error) {

if (fBlockHit)
{
[self showAlert:@"Error!" informativeText:@"Completion block was hit multiple times!"];
return;
}

fBlockHit = YES;
dispatch_async(dispatch_get_main_queue(), ^{

if (!result)
{
[self updateResultViewError:error];
}
[self.webView setHidden:YES];

[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
[[MSIDExecutionFlowLogger sharedInstance] retrieveAndFlushExecutionFlowWithCorrelationId:correlationId queryKeys:nil completion:^(NSString * _Nullable executionFlow) {
dispatch_async(dispatch_get_main_queue(), ^{

if (!result)
{
[self updateResultViewError:error executionFlow:executionFlow];
}

[self.webView setHidden:YES];

[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
}];
};

MSALInteractiveTokenParameters *parameters = [self tokenParamsWithSSOSeeding:YES];
parameters.correlationId = correlationId;
[[MSIDExecutionFlowLogger sharedInstance] registerExecutionFlowWithCorrelationId:correlationId];
[application acquireTokenWithParameters:parameters completionBlock:completionBlock];
}

Expand Down Expand Up @@ -547,7 +555,9 @@ - (IBAction)acquireTokenSilent:(id)sender
parameters.authenticationScheme = [self authScheme];
parameters.msalXpcMode = [self xpcMode];
parameters.extraQueryParameters = extraQueryParameters;

NSUUID *uuid = [NSUUID UUID];
parameters.correlationId = uuid;
[[MSIDExecutionFlowLogger sharedInstance] registerExecutionFlowWithCorrelationId:uuid];
void (^acquireTokenSilentBlock)(void) = ^{
NSDate *startTime = [NSDate date];
BOOL isXpcPressureTest = [self xpcPressureTest];
Expand All @@ -565,23 +575,25 @@ - (IBAction)acquireTokenSilent:(id)sender
}
fBlockHit = YES;
}

NSDate *endTime = [NSDate date];
NSTimeInterval elapsedTime = [endTime timeIntervalSinceDate:startTime];

NSLog(@"Benchmarking: %f seconds", elapsedTime);

dispatch_async(dispatch_get_main_queue(), ^{
if (result)
{
[self updateResultView:result];
}
else
{
[self updateResultViewError:error];
}
[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
[[MSIDExecutionFlowLogger sharedInstance] retrieveAndFlushExecutionFlowWithCorrelationId:uuid queryKeys:nil completion:^(NSString * _Nullable executionFlow) {
NSDate *endTime = [NSDate date];
NSTimeInterval elapsedTime = [endTime timeIntervalSinceDate:startTime];

NSLog(@"Benchmarking: %f seconds", elapsedTime);

dispatch_async(dispatch_get_main_queue(), ^{
if (result)
{
[self updateResultView:result executionFlow:executionFlow];
}
else
{
[self updateResultViewError:error executionFlow:executionFlow];
}
[[NSNotificationCenter defaultCenter] postNotificationName:MSALTestAppCacheChangeNotification object:self];
});
}];
}];
};

Expand Down Expand Up @@ -655,7 +667,7 @@ - (IBAction)signout:(__unused id)sender
{
if (!success)
{
[self updateResultViewError:error];
[self updateResultViewError:error executionFlow:nil];
}
else
{
Expand Down
Loading