Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] feedback PR for perf improvements #1084

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 82 additions & 82 deletions .sonarlint/azuread_microsoft-identity-web/CSharp/SonarLint.xml
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<AnalysisInput xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Settings>
<Setting>
<Key>sonar.cs.analyzeGeneratedCode</Key>
<Value>false</Value>
</Setting>
<Setting>
<Key>sonar.cs.file.suffixes</Key>
<Value>.cs</Value>
</Setting>
<Setting>
<Key>sonar.cs.ignoreHeaderComments</Key>
<Value>true</Value>
</Setting>
<Setting>
<Key>sonar.cs.roslyn.ignoreIssues</Key>
<Value>false</Value>
</Setting>
<Setting>
<Key>sonar.cs.analyzeGeneratedCode</Key>
<Value>false</Value>
</Setting>
<Setting>
<Key>sonar.cs.file.suffixes</Key>
<Value>.cs</Value>
</Setting>
<Setting>
<Key>sonar.cs.ignoreHeaderComments</Key>
<Value>true</Value>
</Setting>
<Setting>
<Key>sonar.cs.roslyn.ignoreIssues</Key>
<Value>false</Value>
</Setting>
</Settings>
<Rules>
<Rule>
<Key>S107</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>7</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S110</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>5</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S1479</Key>
<Parameters>
<Parameter>
<Key>maximum</Key>
<Value>30</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S2342</Key>
<Parameters>
<Parameter>
<Key>flagsAttributeFormat</Key>
<Value>^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$</Value>
</Parameter>
<Parameter>
<Key>format</Key>
<Value>^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S2436</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>2</Value>
</Parameter>
<Parameter>
<Key>maxMethod</Key>
<Value>3</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S3776</Key>
<Parameters>
<Parameter>
<Key>propertyThreshold</Key>
<Value>3</Value>
</Parameter>
<Parameter>
<Key>threshold</Key>
<Value>15</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S107</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>7</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S110</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>5</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S1479</Key>
<Parameters>
<Parameter>
<Key>maximum</Key>
<Value>30</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S2342</Key>
<Parameters>
<Parameter>
<Key>flagsAttributeFormat</Key>
<Value>^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$</Value>
</Parameter>
<Parameter>
<Key>format</Key>
<Value>^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S2436</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>2</Value>
</Parameter>
<Parameter>
<Key>maxMethod</Key>
<Value>3</Value>
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S3776</Key>
<Parameters>
<Parameter>
<Key>propertyThreshold</Key>
<Value>3</Value>
</Parameter>
<Parameter>
<Key>threshold</Key>
<Value>15</Value>
</Parameter>
</Parameters>
</Rule>
</Rules>
</AnalysisInput>
34 changes: 17 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License
MIT License

Copyright (c) Microsoft Corporation.
Copyright (c) Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
64 changes: 32 additions & 32 deletions src/Microsoft.Identity.Web/AccountExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@

namespace Microsoft.Identity.Web
{
/// <summary>
/// Extension methods for <see cref="IAccount"/>.
/// </summary>
public static class AccountExtensions
{
/// <summary>
/// Creates the <see cref="ClaimsPrincipal"/> from the values found
/// in an <see cref="IAccount"/>.
/// </summary>
/// <param name="account">The <see cref="IAccount"/> instance.</param>
/// <returns>A <see cref="ClaimsPrincipal"/> built from <see cref="IAccount"/>.</returns>
public static ClaimsPrincipal ToClaimsPrincipal(this IAccount account)
{
if (account == null)
{
throw new ArgumentNullException(nameof(account));
}
/// <summary>
/// Extension methods for <see cref="IAccount"/>.
/// </summary>
public static class AccountExtensions
{
/// <summary>
/// Creates the <see cref="ClaimsPrincipal"/> from the values found
/// in an <see cref="IAccount"/>.
/// </summary>
/// <param name="account">The <see cref="IAccount"/> instance.</param>
/// <returns>A <see cref="ClaimsPrincipal"/> built from <see cref="IAccount"/>.</returns>
public static ClaimsPrincipal ToClaimsPrincipal(this IAccount account)
{
if (account == null)
{
throw new ArgumentNullException(nameof(account));
}

ClaimsIdentity identity = new ClaimsIdentity(new Claim[]
{
new Claim(ClaimTypes.Upn, account.Username),
});
ClaimsIdentity identity = new ClaimsIdentity(new Claim[]
{
new Claim(ClaimTypes.Upn, account.Username),
});

if (!string.IsNullOrEmpty(account.HomeAccountId?.ObjectId))
{
identity.AddClaim(new Claim(ClaimConstants.Oid, account.HomeAccountId.ObjectId));
}
if (!string.IsNullOrEmpty(account.HomeAccountId?.ObjectId))
{
identity.AddClaim(new Claim(ClaimConstants.Oid, account.HomeAccountId.ObjectId));
}

if (!string.IsNullOrEmpty(account.HomeAccountId?.TenantId))
{
identity.AddClaim(new Claim(ClaimConstants.Tid, account.HomeAccountId.TenantId));
}
if (!string.IsNullOrEmpty(account.HomeAccountId?.TenantId))
{
identity.AddClaim(new Claim(ClaimConstants.Tid, account.HomeAccountId.TenantId));
}

return new ClaimsPrincipal(identity);
}
}
return new ClaimsPrincipal(identity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@

namespace Microsoft.Identity.Web
{
/// <summary>
/// Extension methods related to App Services authentication (Easy Auth).
/// </summary>
public static class AppServicesAuthenticationBuilderExtensions
{
/// <summary>
/// Add authentication with App Services.
/// </summary>
/// <param name="builder">Authentication builder.</param>
/// <returns>The builder, to chain commands.</returns>
public static AuthenticationBuilder AddAppServicesAuthentication(
this AuthenticationBuilder builder)
{
if (builder is null)
{
throw new System.ArgumentNullException(nameof(builder));
}
/// <summary>
/// Extension methods related to App Services authentication (Easy Auth).
/// </summary>
public static class AppServicesAuthenticationBuilderExtensions
{
/// <summary>
/// Add authentication with App Services.
/// </summary>
/// <param name="builder">Authentication builder.</param>
/// <returns>The builder, to chain commands.</returns>
public static AuthenticationBuilder AddAppServicesAuthentication(
this AuthenticationBuilder builder)
{
if (builder is null)
{
throw new System.ArgumentNullException(nameof(builder));
}

builder.AddScheme<AppServicesAuthenticationOptions, AppServicesAuthenticationHandler>(
AppServicesAuthenticationDefaults.AuthenticationScheme,
AppServicesAuthenticationDefaults.AuthenticationScheme,
options => { });
builder.AddScheme<AppServicesAuthenticationOptions, AppServicesAuthenticationHandler>(
AppServicesAuthenticationDefaults.AuthenticationScheme,
AppServicesAuthenticationDefaults.AuthenticationScheme,
options => { });

return builder;
}
}
return builder;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace Microsoft.Identity.Web
{
/// <summary>
/// Default values related to AppServiceAuthentication handler.
/// </summary>
public static class AppServicesAuthenticationDefaults
{
/// <summary>
/// The default value used for AppServiceAuthenticationOptions.AuthenticationScheme.
/// </summary>
public const string AuthenticationScheme = "AppServicesAuthentication";
}
/// <summary>
/// Default values related to AppServiceAuthentication handler.
/// </summary>
public static class AppServicesAuthenticationDefaults
{
/// <summary>
/// The default value used for AppServiceAuthenticationOptions.AuthenticationScheme.
/// </summary>
public const string AuthenticationScheme = "AppServicesAuthentication";
}
}
Loading