Skip to content

Commit 50d9cde

Browse files
authored
Merge pull request #57 from codez-one/paje/minor_upgrades
update some dependencies and make it more stable against null ref
2 parents 97ec249 + 360245e commit 50d9cde

8 files changed

Lines changed: 25 additions & 23 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ You can add the package for example with the following `dotnet` command:
1616
dotnet add package CZ.AspNetCore.EasyAuthAuthentication
1717
```
1818

19-
Pre-releases of this Package are pushed to an internal <a href="https://dev.azure.com/czon/CZ.AspNetCore.EasyAuthAuthentication/_artifacts/feed/czon" target="_blank">feed an Azure DevOps</a>.
19+
Pre-releases of this Package are pushed to an internal <a href="https://dev.azure.com/czon/CZ.AspNetCore.EasyAuthAuthentication/_artifacts/feed/CZ.AspNetCore.EasyAuthAuthentication" target="_blank">feed on Azure DevOps</a>.
2020

21-
There are also access to packages from pull requests in another <a href="https://dev.azure.com/czon/CZ.AspNetCore.EasyAuthAuthentication/_artifacts/feed/czon-pr" target="_blank">Azure DevOps feed</a>. All Packages in this feed has a name like this: `PR-{pull request number}-CZ.AspNetCore.EasyAuthAuthentication`. So you must only pick the package of your PR to check your changes in a test project. All changes of the pull request are tracked in the pull request package version history.
21+
> Note: For internal team members, there are also access to packages from pull requests in another <a href="https://dev.azure.com/czon/CZ.AspNetCore.EasyAuthAuthentication/_artifacts/feed/czon-pr" target="_blank">Azure DevOps feed</a>. All Packages in this feed has a name like this: `PR-{pull request number}-CZ.AspNetCore.EasyAuthAuthentication`. So you must only pick the package of your PR to check your changes in a test project. All changes of the pull request are tracked in the pull request package version history.
2222
2323
## Build
2424

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/EasyAuthForAuthorizationTokenService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private IEnumerable<AADClaimsModel> BuildFromAuthToken(JObject xMsClientPrincipa
7676
{
7777
this.logger.LogDebug($"payload was {xMsClientPrincipal[this.defaultOptions.RoleClaimType]}");
7878

79-
claims.AddRange(JsonConvert.DeserializeObject<IEnumerable<string>>(xMsClientPrincipal[this.defaultOptions.RoleClaimType].ToString())
79+
claims.AddRange(JsonConvert.DeserializeObject<IEnumerable<string>>(xMsClientPrincipal[this.defaultOptions.RoleClaimType]?.ToString() ?? "[]")
8080
.Select(r => new AADClaimsModel { Typ = this.defaultOptions.RoleClaimType, Values = r }));
8181
}
8282
var otherClaims = xMsClientPrincipal.Properties()
@@ -88,8 +88,8 @@ private IEnumerable<AADClaimsModel> BuildFromAuthToken(JObject xMsClientPrincipa
8888
{
8989
Typ = options.NameClaimType,
9090
Values = xMsClientPrincipal.ContainsKey("upn") ?
91-
xMsClientPrincipal["upn"].ToString() : // this appends if an user is using the auth token from the /.auth/me site on the website
92-
xMsClientPrincipal["appid"].ToString() // this appends if an application is try accessing the app.
91+
xMsClientPrincipal["upn"]?.ToString() ?? string.Empty : // this appends if an user is using the auth token from the /.auth/me site on the website
92+
xMsClientPrincipal["appid"]?.ToString() ?? string.Empty // this appends if an application is try accessing the app.
9393
});
9494
return claims;
9595
}

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)