Skip to content
Merged
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
6 changes: 4 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net462; net472; net5.0; netstandard2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net462; net472; net6.0; netstandard2.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -72,7 +72,7 @@
<MicrosoftIdentityAbstractions>2.0.1-preview</MicrosoftIdentityAbstractions>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'net5.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'net6.0'">
<MicrosoftAspNetCoreAuthenticationJwtBearerVersion>5.0.12-*</MicrosoftAspNetCoreAuthenticationJwtBearerVersion>
<MicrosoftAspNetCoreAuthenticationOpenIdConnectVersion>5.0.12-*</MicrosoftAspNetCoreAuthenticationOpenIdConnectVersion>
<MicrosoftExtensionsCachingMemoryVersion>5.0.0</MicrosoftExtensionsCachingMemoryVersion>
Expand All @@ -99,6 +99,8 @@
<MicrosoftExtensionsCachingMemoryVersion>2.1.0</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsLoggingVersion>2.1.0</MicrosoftExtensionsLoggingVersion>
<MicrosoftExtensionsDependencyInjectionVersion>2.1.0</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsConfigurationBinderVersion>2.2.4</MicrosoftExtensionsConfigurationBinderVersion>

</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0; net462; net472</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0; net462; net472</TargetFrameworks>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static IAppBuilder AddMicrosoftIdentityWebApp(

string? clientInfo = httpContext.Session[ClaimConstants.ClientInfo] as string;

if (!string.IsNullOrEmpty(clientInfo))
if (clientInfo!=null && !string.IsNullOrEmpty(clientInfo))
{
ClientInfo? clientInfoFromServer = ClientInfo.CreateFromJson(clientInfo);

Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Identity.Web.TokenAcquisition/MergedOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ConfidentialClientApplicationOptions ConfidentialClientApplicationOptions
internal static void UpdateMergedOptionsFromMicrosoftIdentityOptions(MicrosoftIdentityOptions microsoftIdentityOptions, MergedOptions mergedOptions)
{

#if DOTNET_50_AND_ABOVE
#if NET5_0_OR_GREATER
mergedOptions.MapInboundClaims = microsoftIdentityOptions.MapInboundClaims;
#endif

Expand Down Expand Up @@ -136,7 +136,7 @@ internal static void UpdateMergedOptionsFromMicrosoftIdentityOptions(MicrosoftId

mergedOptions.ProtocolValidator ??= microsoftIdentityOptions.ProtocolValidator;

#if DOTNET_50_AND_ABOVE
#if NET5_0_OR_GREATER
mergedOptions.RefreshInterval = microsoftIdentityOptions.RefreshInterval;
#endif
mergedOptions.RefreshOnIssuerKeyNotFound = microsoftIdentityOptions.RefreshOnIssuerKeyNotFound;
Expand Down Expand Up @@ -202,7 +202,7 @@ internal static void UpdateMergedOptionsFromMicrosoftIdentityOptions(MicrosoftId
mergedOptions.Scope.Add(scope);
}
}
#if DOTNET_50_AND_ABOVE
#if NET5_0_OR_GREATER
mergedOptions.AutomaticRefreshInterval = microsoftIdentityOptions.AutomaticRefreshInterval;
#endif
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'netcoreapp3.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftAspNetCoreAuthenticationJwtBearerVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(MicrosoftAspNetCoreAuthenticationOpenIdConnectVersion)" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(IdentityModelVersion)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' Or '$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'net472'">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsConfigurationBinderVersion)" />
</ItemGroup>

Expand All @@ -35,8 +35,6 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsConfigurationBinderVersion)" />
<Compile Remove="AspNetCore\*.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ await L2OperationWithRetryOnFailureAsync(
/// <param name="cacheKey">Key of the cache item to retrieve.</param>
/// <returns>Read blob representing a token cache for the cache key
/// (account or app).</returns>
protected override async Task<byte[]> ReadCacheBytesAsync(string cacheKey)
protected override async Task<byte[]?> ReadCacheBytesAsync(string cacheKey)
{
return await ReadCacheBytesAsync(cacheKey, new CacheSerializerHints()).ConfigureAwait(false);
}
Expand All @@ -149,7 +149,7 @@ protected override async Task<byte[]> ReadCacheBytesAsync(string cacheKey)
/// <param name="cacheSerializerHints">Hints for the cache serialization implementation optimization.</param>
/// <returns>Read blob representing a token cache for the cache key
/// (account or app).</returns>
protected override async Task<byte[]> ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints)
protected override async Task<byte[]?> ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints)
{
const string read = "Read";
byte[]? result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ protected override Task RemoveKeyAsync(string cacheKey)
/// </summary>
/// <param name="cacheKey">Token cache key.</param>
/// <returns>Read Bytes.</returns>
protected override Task<byte[]> ReadCacheBytesAsync(string cacheKey)
protected override Task<byte[]?> ReadCacheBytesAsync(string cacheKey)
{
byte[] tokenCacheBytes = (byte[])_memoryCache.Get(cacheKey);
byte[]? tokenCacheBytes = (byte[]?)_memoryCache.Get(cacheKey);
return Task.FromResult(tokenCacheBytes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.Identity.Client" Version="$(MicrosoftIdentityClientVersion)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'net5.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(MicrosoftExtensionsCachingMemoryVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="$(MicrosoftAspNetCoreDataProtectionVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ private async Task OnBeforeAccessAsync(TokenCacheNotificationArgs args)
{
if (!string.IsNullOrEmpty(args.SuggestedCacheKey))
{
byte[] tokenCacheBytes = await ReadCacheBytesAsync(args.SuggestedCacheKey, CreateHintsFromArgs(args)).ConfigureAwait(false);
byte[]? tokenCacheBytes = await ReadCacheBytesAsync(args.SuggestedCacheKey, CreateHintsFromArgs(args)).ConfigureAwait(false);
if (tokenCacheBytes == null)
{
return;
}

try
{
Expand All @@ -137,7 +141,7 @@ private async Task OnBeforeAccessAsync(TokenCacheNotificationArgs args)
}
}

private byte[] UnprotectBytes(byte[] msalBytes)
private byte[] UnprotectBytes(byte[]? msalBytes)
{
if (msalBytes != null && _protector != null)
{
Expand Down Expand Up @@ -204,15 +208,15 @@ protected virtual Task WriteCacheBytesAsync(string cacheKey, byte[] bytes, Cache
/// </summary>
/// <param name="cacheKey">Cache key.</param>
/// <returns>Read bytes.</returns>
protected abstract Task<byte[]> ReadCacheBytesAsync(string cacheKey);
protected abstract Task<byte[]?> ReadCacheBytesAsync(string cacheKey);

/// <summary>
/// Method to be overridden by concrete cache serializers to Read the cache bytes.
/// </summary>
/// <param name="cacheKey">Cache key.</param>
/// <param name="cacheSerializerHints">Hints for the cache serialization implementation optimization.</param>
/// <returns>Read bytes.</returns>
protected virtual Task<byte[]> ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints)
protected virtual Task<byte[]?> ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints)
{
return ReadCacheBytesAsync(cacheKey); // default implementation avoids a breaking change.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ public IActionResult Challenge(
};

OAuthChallengeProperties oAuthChallengeProperties = new OAuthChallengeProperties(items, parameters);
oAuthChallengeProperties.Scope = scope?.Split(" ");
if (scope != null)
{
oAuthChallengeProperties.Scope = scope.Split(" ");
}
oAuthChallengeProperties.RedirectUri = redirectUri;

return Challenge(
Expand All @@ -114,7 +117,11 @@ public IActionResult SignOut(
{
if (AppServicesAuthenticationInformation.IsAppServicesAadAuthenticationEnabled)
{
return LocalRedirect(AppServicesAuthenticationInformation.LogoutUrl);
if (AppServicesAuthenticationInformation.LogoutUrl != null)
{
return LocalRedirect(AppServicesAuthenticationInformation.LogoutUrl);
}
return Ok();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Identity.Web/AuthorizeForScopesAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public override void OnException(ExceptionContext context)
}
}

base.OnException(context);
base.OnException(context!);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net462; net472; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net462; net472; net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' ">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftAspNetCoreAuthenticationJwtBearerVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(MicrosoftAspNetCoreAuthenticationOpenIdConnectVersion)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MsalSessionTokenCacheProvider(
/// <param name="cacheKey">Key representing the token cache
/// (account or app).</param>
/// <returns>Read blob.</returns>
protected override async Task<byte[]> ReadCacheBytesAsync(string cacheKey)
protected override async Task<byte[]?> ReadCacheBytesAsync(string cacheKey)
{
return await ReadCacheBytesAsync(cacheKey, new CacheSerializerHints()).ConfigureAwait(false);
}
Expand All @@ -65,7 +65,7 @@ protected override async Task<byte[]> ReadCacheBytesAsync(string cacheKey)
/// (account or app).</param>
/// <param name="cacheSerializerHints">Hints for the cache serialization implementation optimization.</param>
/// <returns>Read blob.</returns>
protected override async Task<byte[]> ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints)
protected override async Task<byte[]?> ReadCacheBytesAsync(string cacheKey, CacheSerializerHints cacheSerializerHints)
{
#pragma warning disable CA1062 // Validate arguments of public methods
await _session.LoadAsync(cacheSerializerHints.CancellationToken).ConfigureAwait(false);
Expand All @@ -74,7 +74,7 @@ protected override async Task<byte[]> ReadCacheBytesAsync(string cacheKey, Cache
_sessionLock.EnterReadLock();
try
{
if (_session.TryGetValue(cacheKey, out byte[] blob))
if (_session.TryGetValue(cacheKey, out byte[]? blob))
{
Logger.SessionCache(_logger, "Read", _session.Id, cacheKey, null);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/B2CWebAppCallsWebApi/Client/TodoListClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<UserSecretsId>aspnet-WebApp_OpenIDConnect_DotNet-81EA87AD-E64D-4755-A1CC-5EA47F49B5D9</UserSecretsId>
<WebProject_DirectoryAccessLevelKey>0</WebProject_DirectoryAccessLevelKey>
<CodeAnalysisRuleSet>..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset</CodeAnalysisRuleSet>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<UserSecretsId>aspnet-TodoListService-03230DB1-5145-408C-A48B-BE3DAFC56C30</UserSecretsId>
<WebProject_DirectoryAccessLevelKey>0</WebProject_DirectoryAccessLevelKey>
<CodeAnalysisRuleSet>..\..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset</CodeAnalysisRuleSet>
Expand Down
2 changes: 1 addition & 1 deletion tests/BlazorServerCallsGraph/blazor.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<UserSecretsId>66e5c3c7-f757-4032-bfcf-68bd81948618</UserSecretsId>
<CodeAnalysisRuleSet>..\..\.sonarlint\azuread_microsoft-identity-webcsharp.ruleset</CodeAnalysisRuleSet>
<SonarQubeExclude>True</SonarQubeExclude>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../../build/MSAL.snk</AssemblyOriginatorKeyFile>
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTests/WebAppUiTests/WebAppUiTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net462; net472; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net462; net472; net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>

<IsPackable>false</IsPackable>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ public void TestFromStoreWithThumbprint(string certificateThumbprint, StoreLocat
[Fact]
public void TestFromCertificate()
{
using (X509Certificate2 certificate2 = new X509Certificate2())
{
CertificateDescription certificateDescription =
CertificateDescription.FromCertificate(certificate2);
}
using X509Certificate2 certificate2 = new X509Certificate2(new byte[0]);
CertificateDescription certificateDescription =
CertificateDescription.FromCertificate(certificate2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>$(DefineConstants);DOTNET_CORE_31</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
<DefineConstants>$(DefineConstants);DOTNET_50</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
<DefineConstants>$(DefineConstants);DOTNET_472</DefineConstants>
<LangVersion>8.0</LangVersion>
Expand All @@ -16,14 +13,14 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net462; net472; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net462; net472; net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Condition="'$(TargetFramework)' == 'net5.0' Or '$(TargetFramework)' == 'netcoreapp3.1'" Include="..\..\src\Microsoft.Identity.Web.MicrosoftGraph\Microsoft.Identity.Web.MicrosoftGraph.csproj" />
<ProjectReference Condition="'$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'netcoreapp3.1'" Include="..\..\src\Microsoft.Identity.Web.MicrosoftGraph\Microsoft.Identity.Web.MicrosoftGraph.csproj" />
<ProjectReference Include="..\..\src\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
<ProjectReference Include="..\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj" />
</ItemGroup>
Expand Down
Loading