From a1841c5727971e55ec87ee9864ceff9b3b78ad83 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 1 Apr 2023 22:28:19 +0300 Subject: [PATCH] =?UTF-8?q?2.2.0=20release=20[2023-04-01=2022:24]=20?= =?UTF-8?q?=E2=97=BE=20Tuitio=20nuget=20packages=20upgrade=20=E2=97=BE=20R?= =?UTF-8?q?emoved=20user=20profile=20picture=20url=20from=20authentication?= =?UTF-8?q?=20claims?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constants/ClaimTypes.cs | 3 +-- ...mash.Security.Authentication.Tuitio.csproj | 4 ++-- .../ReleaseNotes.txt | 6 +++++- .../TuitioAuthenticationHandler.cs | 21 +++++++++++++++---- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/security/authentication/Netmash.Security.Authentication.Tuitio/Constants/ClaimTypes.cs b/src/security/authentication/Netmash.Security.Authentication.Tuitio/Constants/ClaimTypes.cs index eb36c35..4a9dc01 100644 --- a/src/security/authentication/Netmash.Security.Authentication.Tuitio/Constants/ClaimTypes.cs +++ b/src/security/authentication/Netmash.Security.Authentication.Tuitio/Constants/ClaimTypes.cs @@ -6,7 +6,6 @@ UserName = "UserName", FirstName = "FirstName", LastName = "LastName", - IsGuestUser = "IsGuestUser", - ProfilePictureUrl = "ProfilePictureUrl"; + IsGuestUser = "IsGuestUser"; } } diff --git a/src/security/authentication/Netmash.Security.Authentication.Tuitio/Netmash.Security.Authentication.Tuitio.csproj b/src/security/authentication/Netmash.Security.Authentication.Tuitio/Netmash.Security.Authentication.Tuitio.csproj index 69e5051..4c18dd7 100644 --- a/src/security/authentication/Netmash.Security.Authentication.Tuitio/Netmash.Security.Authentication.Tuitio.csproj +++ b/src/security/authentication/Netmash.Security.Authentication.Tuitio/Netmash.Security.Authentication.Tuitio.csproj @@ -13,11 +13,11 @@ README.md Toodle HomeLab Toodle Netmash - 2.1.0 + 2.2.0 - + diff --git a/src/security/authentication/Netmash.Security.Authentication.Tuitio/ReleaseNotes.txt b/src/security/authentication/Netmash.Security.Authentication.Tuitio/ReleaseNotes.txt index ea4d814..94891c4 100644 --- a/src/security/authentication/Netmash.Security.Authentication.Tuitio/ReleaseNotes.txt +++ b/src/security/authentication/Netmash.Security.Authentication.Tuitio/ReleaseNotes.txt @@ -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 refactoring diff --git a/src/security/authentication/Netmash.Security.Authentication.Tuitio/TuitioAuthenticationHandler.cs b/src/security/authentication/Netmash.Security.Authentication.Tuitio/TuitioAuthenticationHandler.cs index c613b23..7ebcd71 100644 --- a/src/security/authentication/Netmash.Security.Authentication.Tuitio/TuitioAuthenticationHandler.cs +++ b/src/security/authentication/Netmash.Security.Authentication.Tuitio/TuitioAuthenticationHandler.cs @@ -42,7 +42,7 @@ namespace Netmash.Security.Authentication.Tuitio catch (Exception e) { _logger.LogError(e, "Tuitio authorization failed"); - return AuthenticateResult.Fail("Invalid authorization"); + return AuthenticateResult.Fail("UNAUTHORIZED"); } if (!string.IsNullOrEmpty(authorizationEnvelope.Error)) @@ -59,7 +59,7 @@ namespace Netmash.Security.Authentication.Tuitio return AuthenticateResult.Success(guestTicket); } - return AuthenticateResult.Fail("Missing authorization header"); + return AuthenticateResult.Fail("AUTHORIZATION_HEADER_IS_MISSING"); } private string GetAuthorizationToken() @@ -104,18 +104,31 @@ namespace Netmash.Security.Authentication.Tuitio }; if (authorization.FirstName != null) + { + claimCollection.Add(ClaimTypes.GivenName, authorization.FirstName); claimCollection.Add(Constants.ClaimTypes.FirstName, authorization.FirstName); + } + if (authorization.LastName != null) + { + claimCollection.Add(ClaimTypes.Surname, authorization.FirstName); claimCollection.Add(Constants.ClaimTypes.LastName, authorization.LastName); - if (authorization.ProfilePictureUrl != null) - claimCollection.Add(Constants.ClaimTypes.ProfilePictureUrl, authorization.ProfilePictureUrl); + } + if (authorization.Email != null) claimCollection.Add(ClaimTypes.Email, authorization.Email); if (authorization.Claims != null && authorization.Claims.Any()) { 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); + } } var claims = claimCollection.Select(z => new Claim(z.Key, z.Value)).ToArray();