Skip to content

Commit a4f89b6

Browse files
committed
update some dependencies and make it more stable against null ref
1 parent 97ec249 commit a4f89b6

6 files changed

Lines changed: 20 additions & 18 deletions

File tree

samples/CZ.AspNetCore.EasyAuthAuthentication.Samples.Client/CZ.AspNetCore.EasyAuthAuthentication.Samples.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="5.2.6" />
9+
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="5.2.9" />
1010
</ItemGroup>
1111

1212
</Project>

samples/CZ.AspNetCore.EasyAuthAuthentication.Samples.Web/CZ.AspNetCore.EasyAuthAuthentication.Samples.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.1" />
17+
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.30" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/CZ.AspNetCore.EasyAuthAuthentication/CZ.AspNetCore.EasyAuthAuthentication.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
</PropertyGroup>
4848

4949
<ItemGroup>
50-
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.1.2" />
51-
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
52-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0" />
53-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.0" />
54-
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
55-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.3.0" />
56-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
50+
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
51+
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
52+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
53+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
54+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
55+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.24.0" />
56+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
5757
</ItemGroup>
5858
</Project>

src/CZ.AspNetCore.EasyAuthAuthentication/Services/Base/EasyAuthWithHeaderService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace CZ.AspNetCore.EasyAuthAuthentication.Services.Base
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
56
using System.Security.Claims;
67
using System.Text;
78
using CZ.AspNetCore.EasyAuthAuthentication.Interfaces;
@@ -87,8 +88,8 @@ private AuthenticationTicket BuildIdentityFromEasyAuthRequestHeaders(IHeaderDict
8788
Convert.FromBase64String(headerContent)
8889
)
8990
);
90-
var claims = JsonConvert.DeserializeObject<IEnumerable<AADClaimsModel>>(xMsClientPrincipal["claims"].ToString());
91-
return AuthenticationTicketBuilder.Build(claims, providerName, options);
91+
var claims = JsonConvert.DeserializeObject<IEnumerable<AADClaimsModel>>(xMsClientPrincipal["claims"]?.ToString() ?? "[]");
92+
return AuthenticationTicketBuilder.Build(claims ?? Enumerable.Empty<AADClaimsModel>(), providerName, options);
9293
}
9394

9495
bool IEasyAuthAuthentificationService.CanHandleAuthentification(HttpContext httpContext) => this.CanHandleAuthentification(httpContext);

src/CZ.AspNetCore.EasyAuthAuthentication/Services/LocalAuthMeService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace CZ.AspNetCore.EasyAuthAuthentication.Services
55
{
66
using System;
77
using System.Collections.Generic;
8+
using System.Linq;
89
using System.Net;
910
using System.Net.Http;
1011
using System.Security.Claims;
@@ -87,12 +88,12 @@ private async Task<AuthenticationTicket> CreateUserTicket()
8788

8889
private AuthenticationTicket BuildIdentityFromEasyAuthMeJson(JObject payload)
8990
{
90-
var providerName = payload["provider_name"].Value<string>();
91+
var providerName = payload["provider_name"]?.Value<string>();
9192
this.Logger.LogDebug($"payload was fetched from easyauth me json, provider: {providerName}");
9293

9394
this.Logger.LogInformation("building claims from payload...");
9495
return AuthenticationTicketBuilder.Build(
95-
JsonConvert.DeserializeObject<IEnumerable<AADClaimsModel>>(payload["user_claims"].ToString()),
96+
JsonConvert.DeserializeObject<IEnumerable<AADClaimsModel>>(payload["user_claims"]?.ToString() ?? "[]") ?? Enumerable.Empty<AADClaimsModel>(),
9697
providerName,
9798
this.defaultOptions.GetProviderOptions()
9899
);

test/CZ.AspNetCore.EasyAuthAuthentication.Test/CZ.AspNetCore.EasyAuthAuthentication.Test.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.3" />
9-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.1" />
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
11-
<PackageReference Include="xunit" Version="2.4.1" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
8+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
9+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
11+
<PackageReference Include="xunit" Version="2.4.2" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>

0 commit comments

Comments
 (0)