From 1a073ed8c0f1e6edf7ac929729c4f76251f1fff7 Mon Sep 17 00:00:00 2001 From: jennyf19 Date: Thu, 12 Nov 2020 13:58:15 -0800 Subject: [PATCH] first round of fixing more sc warnings (#753) * first round of fixing more sc warnings * add sonar cloud via vs extension * fix more warnings * change order * fix yml * force re-build * add keyvault build * fix new code warning --- .sonarlint/Microsoft.Identity.Web.slconfig | 15 + .../CSharp/SonarLint.xml | 89 +++++ ...uread_microsoft-identity-webcsharp.ruleset | 368 ++++++++++++++++++ ...icrosoftIdentityWebProjectTemplates.csproj | 6 + azure-pipelines.yml | 7 +- ...crosoft.Identity.Web.MicrosoftGraph.csproj | 5 + .../TokenAcquisitionAuthenticationProvider.cs | 4 +- ...oft.Identity.Web.MicrosoftGraphBeta.csproj | 5 + .../Microsoft.Identity.Web.UI.csproj | 5 + .../ClaimsPrincipalExtensions.cs | 4 +- .../Constants/Constants.cs | 2 + .../DownstreamWebApi.cs | 32 +- .../IDownstreamWebApi.cs | 14 +- .../Microsoft.Identity.Web.csproj | 11 +- .../Microsoft.Identity.Web.xml | 54 +-- .../MicrosoftIdentityCircuitHandler.cs | 2 +- .../MsalAspNetCoreHttpClientFactory.cs | 2 +- .../TokenAcquisition.cs | 20 +- tests/.editorconfig | 6 + .../AjaxCallActionsWithDynamicConsent.csproj | 6 + .../Client/TodoListClient.csproj | 6 + .../TodoListService/TodoListService.csproj | 6 + tests/BlazorServerCallsGraph/blazor.csproj | 5 + ...crosoft.Identity.Web.Perf.Benchmark.csproj | 5 + .../Microsoft.Identity.Web.Perf.Client.csproj | 5 + .../WebAppCallsMicrosoftGraph.csproj | 5 + .../Client/TodoListClient.csproj | 6 + .../TodoListService/TodoListService.csproj | 6 + .../blazor.csproj | 5 + tests/blazorwasm-b2c/blazorwasm2-b2c.csproj | 6 + .../blazorwasm2-b2c-hosted.Client.csproj | 5 + .../blazorwasm2-b2c-hosted.Server.csproj | 5 + .../blazorwasm2-b2c-hosted.Shared.csproj | 6 + ...lazorwasm2-singleOrg-hosted4.Client.csproj | 6 + ...lazorwasm2-singleOrg-hosted4.Server.csproj | 5 + ...lazorwasm2-singleOrg-hosted4.Shared.csproj | 6 + .../ConfigureGeneratedApplications.csproj | 6 + 37 files changed, 674 insertions(+), 77 deletions(-) create mode 100644 .sonarlint/Microsoft.Identity.Web.slconfig create mode 100644 .sonarlint/azuread_microsoft-identity-web/CSharp/SonarLint.xml create mode 100644 .sonarlint/azuread_microsoft-identity-webcsharp.ruleset diff --git a/.sonarlint/Microsoft.Identity.Web.slconfig b/.sonarlint/Microsoft.Identity.Web.slconfig new file mode 100644 index 000000000..2784954db --- /dev/null +++ b/.sonarlint/Microsoft.Identity.Web.slconfig @@ -0,0 +1,15 @@ +{ + "ServerUri": "https://sonarcloud.io/", + "Organization": { + "Key": "azuread", + "Name": "Azure Active Directory" + }, + "ProjectKey": "AzureAD_microsoft-identity-web", + "ProjectName": "microsoft-identity-web", + "Profiles": { + "CSharp": { + "ProfileKey": "AXMqHrScFqF0v-dl6dl_", + "ProfileTimestamp": "2020-10-13T14:12:09Z" + } + } +} \ No newline at end of file diff --git a/.sonarlint/azuread_microsoft-identity-web/CSharp/SonarLint.xml b/.sonarlint/azuread_microsoft-identity-web/CSharp/SonarLint.xml new file mode 100644 index 000000000..21acd70e2 --- /dev/null +++ b/.sonarlint/azuread_microsoft-identity-web/CSharp/SonarLint.xml @@ -0,0 +1,89 @@ + + + + + sonar.cs.analyzeGeneratedCode + false + + + sonar.cs.file.suffixes + .cs + + + sonar.cs.ignoreHeaderComments + true + + + sonar.cs.roslyn.ignoreIssues + false + + + + + S107 + + + max + 7 + + + + + S110 + + + max + 5 + + + + + S1479 + + + maximum + 30 + + + + + S2342 + + + flagsAttributeFormat + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ + + + format + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ + + + + + S2436 + + + max + 2 + + + maxMethod + 3 + + + + + S3776 + + + propertyThreshold + 3 + + + threshold + 15 + + + + + \ No newline at end of file diff --git a/.sonarlint/azuread_microsoft-identity-webcsharp.ruleset b/.sonarlint/azuread_microsoft-identity-webcsharp.ruleset new file mode 100644 index 000000000..e85398ed5 --- /dev/null +++ b/.sonarlint/azuread_microsoft-identity-webcsharp.ruleset @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProjectTemplates/AspNetCoreMicrosoftIdentityWebProjectTemplates.csproj b/ProjectTemplates/AspNetCoreMicrosoftIdentityWebProjectTemplates.csproj index e96b3a903..449809da2 100644 --- a/ProjectTemplates/AspNetCoreMicrosoftIdentityWebProjectTemplates.csproj +++ b/ProjectTemplates/AspNetCoreMicrosoftIdentityWebProjectTemplates.csproj @@ -26,6 +26,8 @@ true false content + ..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True @@ -36,4 +38,8 @@ + + + + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d0f6914dc..d018e7096 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,6 +15,7 @@ jobs: - msbuild steps: - template: build/template-install-dotnet-core.yaml + - template: build/template-install-keyvault-secrets.yaml - task: SonarCloudPrepare@1 inputs: SonarCloud: 'SonarCloud-microsoft_identity_web' @@ -37,9 +38,9 @@ jobs: displayName: 'Run unit tests' inputs: command: test - projects: 'tests/Microsoft.Identity.Web.Test*.csproj' - arguments: '--no-build --no-restore --collect "Code coverage"' + projects: 'tests/**/Microsoft.Identity.Web.Test*.csproj' + arguments: '--collect "Code coverage"' - task: SonarCloudAnalyze@1 - task: SonarCloudPublish@1 inputs: - pollingTimeoutSec: '300' \ No newline at end of file + pollingTimeoutSec: '300' diff --git a/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj b/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj index a31d604ca..521290289 100644 --- a/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj +++ b/src/Microsoft.Identity.Web.MicrosoftGraph/Microsoft.Identity.Web.MicrosoftGraph.csproj @@ -38,6 +38,10 @@ + + + + True @@ -68,6 +72,7 @@ false + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset diff --git a/src/Microsoft.Identity.Web.MicrosoftGraph/TokenAcquisitionAuthenticationProvider.cs b/src/Microsoft.Identity.Web.MicrosoftGraph/TokenAcquisitionAuthenticationProvider.cs index adb67fc57..9e582ca47 100644 --- a/src/Microsoft.Identity.Web.MicrosoftGraph/TokenAcquisitionAuthenticationProvider.cs +++ b/src/Microsoft.Identity.Web.MicrosoftGraph/TokenAcquisitionAuthenticationProvider.cs @@ -20,8 +20,8 @@ public TokenAcquisitionAuthenticationProvider(ITokenAcquisition tokenAcquisition _initialOptions = options; } - private ITokenAcquisition _tokenAcquisition; - private TokenAcquisitionAuthenticationProviderOption _initialOptions; + private readonly ITokenAcquisition _tokenAcquisition; + private readonly TokenAcquisitionAuthenticationProviderOption _initialOptions; /// /// Adds an authorization header to an HttpRequestMessage. diff --git a/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj b/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj index 0ffb5ce69..dd1417fe4 100644 --- a/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj +++ b/src/Microsoft.Identity.Web.MicrosoftGraphBeta/Microsoft.Identity.Web.MicrosoftGraphBeta.csproj @@ -45,6 +45,10 @@ + + + + True @@ -75,6 +79,7 @@ false + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset diff --git a/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj b/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj index 8c42ff0d1..3617da533 100644 --- a/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj +++ b/src/Microsoft.Identity.Web.UI/Microsoft.Identity.Web.UI.csproj @@ -32,6 +32,10 @@ + + + + True @@ -49,6 +53,7 @@ true true enable + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset Microsoft.Identity.Web.UI.xml diff --git a/src/Microsoft.Identity.Web/ClaimsPrincipalExtensions.cs b/src/Microsoft.Identity.Web/ClaimsPrincipalExtensions.cs index b2e00b236..df530c345 100644 --- a/src/Microsoft.Identity.Web/ClaimsPrincipalExtensions.cs +++ b/src/Microsoft.Identity.Web/ClaimsPrincipalExtensions.cs @@ -102,10 +102,10 @@ public static class ClaimsPrincipalExtensions throw new ArgumentNullException(nameof(claimsPrincipal)); } - var tenantId = GetTenantId(claimsPrincipal); + string? tenantId = GetTenantId(claimsPrincipal); string? domainHint = string.IsNullOrWhiteSpace(tenantId) ? null - : tenantId.Equals(Constants.MsaTenantId, StringComparison.OrdinalIgnoreCase) ? Constants.Consumers : Constants.Organizations; + : tenantId!.Equals(Constants.MsaTenantId, StringComparison.OrdinalIgnoreCase) ? Constants.Consumers : Constants.Organizations; return domainHint; } diff --git a/src/Microsoft.Identity.Web/Constants/Constants.cs b/src/Microsoft.Identity.Web/Constants/Constants.cs index 9bcf828d6..be5beca66 100644 --- a/src/Microsoft.Identity.Web/Constants/Constants.cs +++ b/src/Microsoft.Identity.Web/Constants/Constants.cs @@ -60,7 +60,9 @@ public static class Constants internal const string Aliases = "aliases"; // AadIssuerValidator +#pragma warning disable S1075 // URIs should not be hardcoded internal const string AzureADIssuerMetadataUrl = "https://login.microsoftonline.com/common/discovery/instance?authorization_endpoint=https://login.microsoftonline.com/common/oauth2/v2.0/authorize&api-version=1.1"; +#pragma warning restore S1075 // URIs should not be hardcoded internal const string FallbackAuthority = "https://login.microsoftonline.com/"; // RegisterValidAudience diff --git a/src/Microsoft.Identity.Web/DownstreamWebApiSupport/DownstreamWebApi.cs b/src/Microsoft.Identity.Web/DownstreamWebApiSupport/DownstreamWebApi.cs index b37a51d08..e3c6fbfb0 100644 --- a/src/Microsoft.Identity.Web/DownstreamWebApiSupport/DownstreamWebApi.cs +++ b/src/Microsoft.Identity.Web/DownstreamWebApiSupport/DownstreamWebApi.cs @@ -21,10 +21,6 @@ public class DownstreamWebApi : IDownstreamWebApi private readonly HttpClient _httpClient; private readonly IOptionsMonitor _namedDownstreamWebApiOptions; private readonly MicrosoftIdentityOptions _microsoftIdentityOptions; - private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true, - }; /// /// Constructor. @@ -49,12 +45,12 @@ public DownstreamWebApi( /// public async Task CallWebApiForUserAsync( - string optionsInstanceName, - Action? calledDownstreamApiOptionsOverride = null, + string serviceName, + Action? calledDownstreamWebApiOptionsOverride = null, ClaimsPrincipal? user = null, - StringContent? requestContent = null) + StringContent? content = null) { - DownstreamWebApiOptions effectiveOptions = MergeOptions(optionsInstanceName, calledDownstreamApiOptionsOverride); + DownstreamWebApiOptions effectiveOptions = MergeOptions(serviceName, calledDownstreamWebApiOptionsOverride); if (string.IsNullOrEmpty(effectiveOptions.Scopes)) { @@ -84,9 +80,9 @@ public async Task CallWebApiForUserAsync( effectiveOptions.HttpMethod, effectiveOptions.GetApiUrl())) { - if (requestContent != null) + if (content != null) { - httpRequestMessage.Content = requestContent; + httpRequestMessage.Content = content; } httpRequestMessage.Headers.Add( @@ -129,14 +125,14 @@ public async Task CallWebApiForUserAsync( /// public async Task CallWebApiForUserAsync( - string optionsInstanceName, + string serviceName, TInput input, Action? downstreamWebApiOptionsOverride = null, ClaimsPrincipal? user = null) where TOutput : class { HttpResponseMessage response = await CallWebApiForUserAsync( - optionsInstanceName, + serviceName, downstreamWebApiOptionsOverride, user, new StringContent(JsonSerializer.Serialize(input), Encoding.UTF8, "application/json")).ConfigureAwait(false); @@ -164,11 +160,11 @@ public async Task CallWebApiForUserAsync( /// public async Task CallWebApiForAppAsync( - string optionsInstanceName, - Action? downstreamApiOptionsOverride = null, - StringContent? requestContent = null) + string serviceName, + Action? downstreamWebApiOptionsOverride = null, + StringContent? content = null) { - DownstreamWebApiOptions effectiveOptions = MergeOptions(optionsInstanceName, downstreamApiOptionsOverride); + DownstreamWebApiOptions effectiveOptions = MergeOptions(serviceName, downstreamWebApiOptionsOverride); if (effectiveOptions.Scopes == null) { @@ -186,9 +182,9 @@ public async Task CallWebApiForAppAsync( effectiveOptions.HttpMethod, effectiveOptions.GetApiUrl())) { - if (requestContent != null) + if (content != null) { - httpRequestMessage.Content = requestContent; + httpRequestMessage.Content = content; } httpRequestMessage.Headers.Add( diff --git a/src/Microsoft.Identity.Web/DownstreamWebApiSupport/IDownstreamWebApi.cs b/src/Microsoft.Identity.Web/DownstreamWebApiSupport/IDownstreamWebApi.cs index 7c0712eb7..c771bc0c5 100644 --- a/src/Microsoft.Identity.Web/DownstreamWebApiSupport/IDownstreamWebApi.cs +++ b/src/Microsoft.Identity.Web/DownstreamWebApiSupport/IDownstreamWebApi.cs @@ -52,11 +52,11 @@ public Task CallWebApiForUserAsync( /// will find the user from the HttpContext. /// The value returned by the downstream web API. /// - /// A list method that returns an IEnumerable<Todo>>. + /// A list method that returns an IEnumerable<MyItem>>. /// - /// public async Task<IEnumerable<Todo>> GetAsync() + /// public async Task<IEnumerable<MyItem>> GetAsync() /// { - /// return await _downstreamWebApi.CallWebApiForUserAsync<object, IEnumerable<Todo>>( + /// return await _downstreamWebApi.CallWebApiForUserAsync<object, IEnumerable<MyItem>>( /// ServiceName, /// null, /// options => @@ -68,15 +68,15 @@ public Task CallWebApiForUserAsync( /// /// Example of editing. /// - /// public async Task<Todo> EditAsync(Todo todo) + /// public async Task<MyItem> EditAsync(MyItem myItem) /// { - /// return await _downstreamWebApi.CallWebApiForUserAsync<Todo, Todo>( + /// return await _downstreamWebApi.CallWebApiForUserAsync<MyItem, MyItem>( /// ServiceName, - /// todo, + /// nyItem, /// options => /// { /// options.HttpMethod = HttpMethod.Patch; - /// options.RelativePath = $"api/todolist/{todo.Id}"; + /// options.RelativePath = $"api/todolist/{myItem.Id}"; /// }); /// } /// diff --git a/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj b/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj index c3f442c98..b2020421f 100644 --- a/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj +++ b/src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj @@ -37,6 +37,10 @@ + + + + True @@ -68,6 +72,7 @@ false + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset @@ -85,7 +90,7 @@ - + @@ -112,10 +117,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - all diff --git a/src/Microsoft.Identity.Web/Microsoft.Identity.Web.xml b/src/Microsoft.Identity.Web/Microsoft.Identity.Web.xml index 75e3f0c1a..513930656 100644 --- a/src/Microsoft.Identity.Web/Microsoft.Identity.Web.xml +++ b/src/Microsoft.Identity.Web/Microsoft.Identity.Web.xml @@ -757,6 +757,24 @@ will find the user from the HttpContext. A strongly typed response from the web API. + + + Call a web API with a strongly typed input, with an HttpGet. + + Input type. + The downstream web API. + Name of the service describing the downstream web API. There can + be several configuration named sections mapped to a , + each for one downstream web API. You can pass-in null, but in that case + needs to be set. + Input data. + Overrides the options proposed in the configuration described + by . + [Optional] Claims representing a user. This is useful in platforms like Blazor + or Azure Signal R, where the HttpContext is not available. In other platforms, the library + will find the user from the HttpContext. + The value returned by the downstream web API. + Calls the web API with an HttpPost, providing strongly typed input and getting @@ -836,24 +854,6 @@ will find the user from the HttpContext. The value returned by the downstream web API. - - - Call a web API with a strongly typed input, with an HttpGet. - - Input type. - The downstream web API. - Name of the service describing the downstream web API. There can - be several configuration named sections mapped to a , - each for one downstream web API. You can pass-in null, but in that case - needs to be set. - Input data. - Overrides the options proposed in the configuration described - by . - [Optional] Claims representing a user. This is useful in platforms like Blazor - or Azure Signal R, where the HttpContext is not available. In other platforms, the library - will find the user from the HttpContext. - The value returned by the downstream web API. - Options passed-in to call downstream web APIs. To call Microsoft Graph, see rather @@ -959,11 +959,11 @@ will find the user from the HttpContext. The value returned by the downstream web API. - A list method that returns an IEnumerable<Todo>>. + A list method that returns an IEnumerable<MyItem>>. - public async Task<IEnumerable<Todo>> GetAsync() + public async Task<IEnumerable<MyItem>> GetAsync() { - return await _downstreamWebApi.CallWebApiForUserAsync<object, IEnumerable<Todo>>( + return await _downstreamWebApi.CallWebApiForUserAsync<object, IEnumerable<MyItem>>( ServiceName, null, options => @@ -975,15 +975,15 @@ Example of editing. - public async Task<Todo> EditAsync(Todo todo) + public async Task<MyItem> EditAsync(MyItem myItem) { - return await _downstreamWebApi.CallWebApiForUserAsync<Todo, Todo>( + return await _downstreamWebApi.CallWebApiForUserAsync<MyItem, MyItem>( ServiceName, - todo, + nyItem, options => { options.HttpMethod = HttpMethod.Patch; - options.RelativePath = $"api/todolist/{todo.Id}"; + options.RelativePath = $"api/todolist/{myItem.Id}"; }); } @@ -1811,7 +1811,7 @@ instance of the current HttpContext. Scopes to request for the downstream API to call. - Enables overriding of the tenant/account for the same identity. This is useful in the + Enables overriding of the tenant/account for the same identity. This is useful in the cases where a given account is a guest in other tenants, and you want to acquire tokens for a specific tenant, like where the user is a guest. Azure AD B2C user flow to target. Optional claims principal representing the user. If not provided, will use the signed-in @@ -1850,7 +1850,7 @@ instance of the current HttpContext. Scopes to request for the downstream API to call. - Enables overriding of the tenant/account for the same identity. This is useful in the + Enables overriding of the tenant/account for the same identity. This is useful in the cases where a given account is a guest in other tenants, and you want to acquire tokens for a specific tenant. Azure AD B2C user flow to target. Optional claims principal representing the user. If not provided, will use the signed-in diff --git a/src/Microsoft.Identity.Web/MicrosoftIdentityCircuitHandler.cs b/src/Microsoft.Identity.Web/MicrosoftIdentityCircuitHandler.cs index 93bf15d8d..586e1a109 100644 --- a/src/Microsoft.Identity.Web/MicrosoftIdentityCircuitHandler.cs +++ b/src/Microsoft.Identity.Web/MicrosoftIdentityCircuitHandler.cs @@ -53,7 +53,7 @@ public class MicrosoftIdentityConsentAndConditionalAccessHandler private ClaimsPrincipal? _user; private string? _baseUri; #pragma warning disable CS8602 // Dereference of a possibly null reference. HttpContext will not be null in this case. - private IHttpContextAccessor? _httpContextAccessor; + private readonly IHttpContextAccessor? _httpContextAccessor; #pragma warning restore CS8602 // Dereference of a possibly null reference. HttpContext will not be null in this case. /// diff --git a/src/Microsoft.Identity.Web/MsalAspNetCoreHttpClientFactory.cs b/src/Microsoft.Identity.Web/MsalAspNetCoreHttpClientFactory.cs index 9b97fa890..a97e683c4 100644 --- a/src/Microsoft.Identity.Web/MsalAspNetCoreHttpClientFactory.cs +++ b/src/Microsoft.Identity.Web/MsalAspNetCoreHttpClientFactory.cs @@ -8,7 +8,7 @@ namespace Microsoft.Identity.Web { internal class MsalAspNetCoreHttpClientFactory : IMsalHttpClientFactory { - private IHttpClientFactory _httpClientFactory; + private readonly IHttpClientFactory _httpClientFactory; public MsalAspNetCoreHttpClientFactory(IHttpClientFactory httpClientFactory) { diff --git a/src/Microsoft.Identity.Web/TokenAcquisition.cs b/src/Microsoft.Identity.Web/TokenAcquisition.cs index 2229d5309..b01513cbe 100644 --- a/src/Microsoft.Identity.Web/TokenAcquisition.cs +++ b/src/Microsoft.Identity.Web/TokenAcquisition.cs @@ -176,7 +176,7 @@ public async Task AddAccountToCacheFromAuthorizationCodeAsync( /// instance of the current HttpContext. /// /// Scopes to request for the downstream API to call. - /// Enables overriding of the tenant/account for the same identity. This is useful in the + /// Enables overriding of the tenant/account for the same identity. This is useful in the /// cases where a given account is a guest in other tenants, and you want to acquire tokens for a specific tenant, like where the user is a guest. /// Azure AD B2C user flow to target. /// Optional claims principal representing the user. If not provided, will use the signed-in @@ -191,7 +191,7 @@ public async Task AddAccountToCacheFromAuthorizationCodeAsync( /// OpenIdConnectOptions.Events.OnAuthorizationCodeReceived. public async Task GetAuthenticationResultForUserAsync( IEnumerable scopes, - string? tenant = null, + string? tenantId = null, string? userFlow = null, ClaimsPrincipal? user = null, TokenAcquisitionOptions? tokenAcquisitionOptions = null) @@ -205,7 +205,7 @@ public async Task GetAuthenticationResultForUserAsync( _application = await GetOrBuildConfidentialClientApplicationAsync().ConfigureAwait(false); - string authority = CreateAuthorityBasedOnTenantIfProvided(_application, tenant); + string authority = CreateAuthorityBasedOnTenantIfProvided(_application, tenantId); AuthenticationResult? authenticationResult; @@ -309,7 +309,7 @@ public async Task GetAccessTokenForAppAsync( /// instance of the current HttpContext. /// /// Scopes to request for the downstream API to call. - /// Enables overriding of the tenant/account for the same identity. This is useful in the + /// Enables overriding of the tenant/account for the same identity. This is useful in the /// cases where a given account is a guest in other tenants, and you want to acquire tokens for a specific tenant. /// Azure AD B2C user flow to target. /// Optional claims principal representing the user. If not provided, will use the signed-in @@ -324,7 +324,7 @@ public async Task GetAccessTokenForAppAsync( /// OpenIdConnectOptions.Events.OnAuthorizationCodeReceived. public async Task GetAccessTokenForUserAsync( IEnumerable scopes, - string? tenant = null, + string? tenantId = null, string? userFlow = null, ClaimsPrincipal? user = null, TokenAcquisitionOptions? tokenAcquisitionOptions = null) @@ -332,7 +332,7 @@ public async Task GetAccessTokenForUserAsync( AuthenticationResult result = await GetAuthenticationResultForUserAsync( scopes, - tenant, + tenantId, userFlow, user, tokenAcquisitionOptions).ConfigureAwait(false); @@ -352,12 +352,9 @@ public async Task ReplyForbiddenWithWwwAuthenticateHeaderAsync(IEnumerable netcoreapp3.1 NU1605 + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + + diff --git a/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj b/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj index 58fd87996..af4a40e57 100644 --- a/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj +++ b/tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj @@ -4,6 +4,8 @@ netcoreapp3.1; net5.0 aspnet-WebApp_OpenIDConnect_DotNet-81EA87AD-E64D-4755-A1CC-5EA47F49B5D9 0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True @@ -21,6 +23,10 @@ + + + + diff --git a/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj b/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj index fb0389417..ae469b87b 100644 --- a/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj +++ b/tests/B2CWebAppCallsWebApi/TodoListService/TodoListService.csproj @@ -4,8 +4,14 @@ netcoreapp3.1; net5.0 aspnet-TodoListService-03230DB1-5145-408C-A48B-BE3DAFC56C30 0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + + diff --git a/tests/BlazorServerCallsGraph/blazor.csproj b/tests/BlazorServerCallsGraph/blazor.csproj index d78cf8ea2..d306a7238 100644 --- a/tests/BlazorServerCallsGraph/blazor.csproj +++ b/tests/BlazorServerCallsGraph/blazor.csproj @@ -2,7 +2,12 @@ netcoreapp3.1; net5.0 66e5c3c7-f757-4032-bfcf-68bd81948618 + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + diff --git a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj index c5a582e28..23b0130a2 100644 --- a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj +++ b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Benchmark/Microsoft.Identity.Web.Perf.Benchmark.csproj @@ -3,8 +3,13 @@ Exe netcoreapp3.1 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + + + + diff --git a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj index ab5d4ca8f..3f03f49f4 100644 --- a/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj +++ b/tests/PerformanceTests/Microsoft.Identity.Web.Perf.Client/Microsoft.Identity.Web.Perf.Client.csproj @@ -3,8 +3,13 @@ Exe netcoreapp3.1 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + + + + diff --git a/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj b/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj index 2a3d90149..25207d78e 100644 --- a/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj +++ b/tests/WebAppCallsMicrosoftGraph/WebAppCallsMicrosoftGraph.csproj @@ -2,7 +2,12 @@ netcoreapp3.1; net5.0 aspnet-WebApp_OpenIDConnect_DotNet-81EA87AD-E64D-4755-A1CC-5EA47F49B5D8 + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + diff --git a/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj b/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj index a5d48f1dd..0931d2eb9 100644 --- a/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj +++ b/tests/WebAppCallsWebApiCallsGraph/Client/TodoListClient.csproj @@ -4,6 +4,8 @@ netcoreapp3.1; net5.0 aspnet-WebApp_OpenIDConnect_DotNet-81EA87AD-E64D-4755-A1CC-5EA47F49B5D0 0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True @@ -21,6 +23,10 @@ + + + + diff --git a/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj b/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj index 50014080b..b4fbf27ef 100644 --- a/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj +++ b/tests/WebAppCallsWebApiCallsGraph/TodoListService/TodoListService.csproj @@ -4,8 +4,14 @@ netcoreapp3.1; net5.0 aspnet-TodoListService-03230DB1-5145-408C-A48B-BE3DAFC56C30 0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + + diff --git a/tests/blazorserver2-b2c-callswebapi/blazor.csproj b/tests/blazorserver2-b2c-callswebapi/blazor.csproj index 6f39697f6..78b89255c 100644 --- a/tests/blazorserver2-b2c-callswebapi/blazor.csproj +++ b/tests/blazorserver2-b2c-callswebapi/blazor.csproj @@ -2,7 +2,12 @@ netcoreapp3.1; net5.0 66e5c3c7-f757-4032-bfcf-68bd81948618 + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + diff --git a/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj b/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj index b23107a50..3e2cbf3d5 100644 --- a/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj +++ b/tests/blazorwasm-b2c/blazorwasm2-b2c.csproj @@ -4,6 +4,8 @@ browser-wasm true 3.0 + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True @@ -22,5 +24,9 @@ + + + + diff --git a/tests/blazorwasm2-b2c-hosted/Client/blazorwasm2-b2c-hosted.Client.csproj b/tests/blazorwasm2-b2c-hosted/Client/blazorwasm2-b2c-hosted.Client.csproj index c6c336d88..947bfd289 100644 --- a/tests/blazorwasm2-b2c-hosted/Client/blazorwasm2-b2c-hosted.Client.csproj +++ b/tests/blazorwasm2-b2c-hosted/Client/blazorwasm2-b2c-hosted.Client.csproj @@ -2,7 +2,12 @@ netstandard2.1 3.0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + diff --git a/tests/blazorwasm2-b2c-hosted/Server/blazorwasm2-b2c-hosted.Server.csproj b/tests/blazorwasm2-b2c-hosted/Server/blazorwasm2-b2c-hosted.Server.csproj index 121a4a44d..f6339553f 100644 --- a/tests/blazorwasm2-b2c-hosted/Server/blazorwasm2-b2c-hosted.Server.csproj +++ b/tests/blazorwasm2-b2c-hosted/Server/blazorwasm2-b2c-hosted.Server.csproj @@ -2,12 +2,17 @@ netcoreapp3.1 + + + 0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True diff --git a/tests/blazorwasm2-b2c-hosted/Shared/blazorwasm2-b2c-hosted.Shared.csproj b/tests/blazorwasm2-b2c-hosted/Shared/blazorwasm2-b2c-hosted.Shared.csproj index d4c395e8c..f8c812e41 100644 --- a/tests/blazorwasm2-b2c-hosted/Shared/blazorwasm2-b2c-hosted.Shared.csproj +++ b/tests/blazorwasm2-b2c-hosted/Shared/blazorwasm2-b2c-hosted.Shared.csproj @@ -2,6 +2,12 @@ netstandard2.1 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + + diff --git a/tests/blazorwasm2/Client/blazorwasm2-singleOrg-hosted4.Client.csproj b/tests/blazorwasm2/Client/blazorwasm2-singleOrg-hosted4.Client.csproj index 2da372ba4..8eac0051b 100644 --- a/tests/blazorwasm2/Client/blazorwasm2-singleOrg-hosted4.Client.csproj +++ b/tests/blazorwasm2/Client/blazorwasm2-singleOrg-hosted4.Client.csproj @@ -3,8 +3,14 @@ netstandard2.1 3.0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + + diff --git a/tests/blazorwasm2/Server/blazorwasm2-singleOrg-hosted4.Server.csproj b/tests/blazorwasm2/Server/blazorwasm2-singleOrg-hosted4.Server.csproj index 2adbf52c6..90ede4291 100644 --- a/tests/blazorwasm2/Server/blazorwasm2-singleOrg-hosted4.Server.csproj +++ b/tests/blazorwasm2/Server/blazorwasm2-singleOrg-hosted4.Server.csproj @@ -2,12 +2,17 @@ netcoreapp3.1 + + + 0 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True diff --git a/tests/blazorwasm2/Shared/blazorwasm2-singleOrg-hosted4.Shared.csproj b/tests/blazorwasm2/Shared/blazorwasm2-singleOrg-hosted4.Shared.csproj index 3e2a547e1..0bca2a6c6 100644 --- a/tests/blazorwasm2/Shared/blazorwasm2-singleOrg-hosted4.Shared.csproj +++ b/tests/blazorwasm2/Shared/blazorwasm2-singleOrg-hosted4.Shared.csproj @@ -2,6 +2,12 @@ netstandard2.1 + ..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + + diff --git a/tools/ConfigureGeneratedApplications/ConfigureGeneratedApplications.csproj b/tools/ConfigureGeneratedApplications/ConfigureGeneratedApplications.csproj index 8fcdd55e3..c669fc0df 100644 --- a/tools/ConfigureGeneratedApplications/ConfigureGeneratedApplications.csproj +++ b/tools/ConfigureGeneratedApplications/ConfigureGeneratedApplications.csproj @@ -3,8 +3,14 @@ Exe netcoreapp3.1 + ..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset + True + + + +