2.2.0 release [2023-04-01 22:24]

 Tuitio nuget packages upgrade
 Removed user profile picture url from authentication claims
master
Tudor Stanciu 2023-04-01 22:28:19 +03:00
parent 15149d9d18
commit a1841c5727
4 changed files with 25 additions and 9 deletions

View File

@ -6,7 +6,6 @@
UserName = "UserName", UserName = "UserName",
FirstName = "FirstName", FirstName = "FirstName",
LastName = "LastName", LastName = "LastName",
IsGuestUser = "IsGuestUser", IsGuestUser = "IsGuestUser";
ProfilePictureUrl = "ProfilePictureUrl";
} }
} }

View File

@ -13,11 +13,11 @@
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<Company>Toodle HomeLab</Company> <Company>Toodle HomeLab</Company>
<Copyright>Toodle Netmash</Copyright> <Copyright>Toodle Netmash</Copyright>
<Version>2.1.0</Version> <Version>2.2.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Tuitio.Wrapper" Version="2.1.0" /> <PackageReference Include="Tuitio.Wrapper" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
</ItemGroup> </ItemGroup>

View File

@ -1,4 +1,8 @@
2.1.0 release [2023-03-07 23:35] 2.2.0 release [2023-04-01 22:24]
◾ Tuitio nuget packages upgrade
◾ Removed user profile picture url from authentication claims
2.1.0 release [2023-03-07 23:35]
◾ Tuitio nuget packages upgrade ◾ Tuitio nuget packages upgrade
◾ Tuitio refactoring ◾ Tuitio refactoring

View File

@ -42,7 +42,7 @@ namespace Netmash.Security.Authentication.Tuitio
catch (Exception e) catch (Exception e)
{ {
_logger.LogError(e, "Tuitio authorization failed"); _logger.LogError(e, "Tuitio authorization failed");
return AuthenticateResult.Fail("Invalid authorization"); return AuthenticateResult.Fail("UNAUTHORIZED");
} }
if (!string.IsNullOrEmpty(authorizationEnvelope.Error)) if (!string.IsNullOrEmpty(authorizationEnvelope.Error))
@ -59,7 +59,7 @@ namespace Netmash.Security.Authentication.Tuitio
return AuthenticateResult.Success(guestTicket); return AuthenticateResult.Success(guestTicket);
} }
return AuthenticateResult.Fail("Missing authorization header"); return AuthenticateResult.Fail("AUTHORIZATION_HEADER_IS_MISSING");
} }
private string GetAuthorizationToken() private string GetAuthorizationToken()
@ -104,18 +104,31 @@ namespace Netmash.Security.Authentication.Tuitio
}; };
if (authorization.FirstName != null) if (authorization.FirstName != null)
{
claimCollection.Add(ClaimTypes.GivenName, authorization.FirstName);
claimCollection.Add(Constants.ClaimTypes.FirstName, authorization.FirstName); claimCollection.Add(Constants.ClaimTypes.FirstName, authorization.FirstName);
}
if (authorization.LastName != null) if (authorization.LastName != null)
{
claimCollection.Add(ClaimTypes.Surname, authorization.FirstName);
claimCollection.Add(Constants.ClaimTypes.LastName, authorization.LastName); claimCollection.Add(Constants.ClaimTypes.LastName, authorization.LastName);
if (authorization.ProfilePictureUrl != null) }
claimCollection.Add(Constants.ClaimTypes.ProfilePictureUrl, authorization.ProfilePictureUrl);
if (authorization.Email != null) if (authorization.Email != null)
claimCollection.Add(ClaimTypes.Email, authorization.Email); claimCollection.Add(ClaimTypes.Email, authorization.Email);
if (authorization.Claims != null && authorization.Claims.Any()) if (authorization.Claims != null && authorization.Claims.Any())
{ {
foreach (var claim in authorization.Claims) foreach (var claim in authorization.Claims)
{
if (claimCollection.ContainsKey(claim.Key))
{
_logger.LogWarning($"There is already a claim with key {claim.Key} in the collection. The combination {claim.Key}:{claim.Value} will be ignored.");
continue;
}
claimCollection.Add(claim.Key, claim.Value); claimCollection.Add(claim.Key, claim.Value);
}
} }
var claims = claimCollection.Select(z => new Claim(z.Key, z.Value)).ToArray(); var claims = claimCollection.Select(z => new Claim(z.Key, z.Value)).ToArray();