diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs index df78846..88adc41 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs @@ -707,6 +707,7 @@ public partial class AddUserRequestContract : System.ComponentModel.INotifyPrope { private string _userName; private string _password; + private string _whiteLabelKey; [Newtonsoft.Json.JsonProperty("userName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string UserName @@ -738,6 +739,21 @@ public string Password } } + [Newtonsoft.Json.JsonProperty("whiteLabelKey", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string WhiteLabelKey + { + get { return _whiteLabelKey; } + + set + { + if (_whiteLabelKey != value) + { + _whiteLabelKey = value; + RaisePropertyChanged(); + } + } + } + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) @@ -751,8 +767,24 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")] public partial class ApplicationInitializeRequestContract : System.ComponentModel.INotifyPropertyChanged { + private string _whiteLabelKey; private string _language; + [Newtonsoft.Json.JsonProperty("whiteLabelKey", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string WhiteLabelKey + { + get { return _whiteLabelKey; } + + set + { + if (_whiteLabelKey != value) + { + _whiteLabelKey = value; + RaisePropertyChanged(); + } + } + } + [Newtonsoft.Json.JsonProperty("language", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Language { @@ -1595,10 +1627,26 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")] public partial class UserClaimContract : System.ComponentModel.INotifyPropertyChanged { + private string _whiteLabelKey; private string _userName; private string _password; private System.Collections.Generic.ICollection _claims; + [Newtonsoft.Json.JsonProperty("whiteLabelKey", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string WhiteLabelKey + { + get { return _whiteLabelKey; } + + set + { + if (_whiteLabelKey != value) + { + _whiteLabelKey = value; + RaisePropertyChanged(); + } + } + } + [Newtonsoft.Json.JsonProperty("userName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string UserName { @@ -1765,9 +1813,25 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")] public partial class UserSummaryContract : System.ComponentModel.INotifyPropertyChanged { + private string _whiteLabelKey; private string _userName; private string _password; + [Newtonsoft.Json.JsonProperty("whiteLabelKey", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string WhiteLabelKey + { + get { return _whiteLabelKey; } + + set + { + if (_whiteLabelKey != value) + { + _whiteLabelKey = value; + RaisePropertyChanged(); + } + } + } + [Newtonsoft.Json.JsonProperty("userName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string UserName { diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json index 47001e0..2abd723 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json @@ -362,6 +362,10 @@ "password": { "type": "string", "nullable": true + }, + "whiteLabelKey": { + "type": "string", + "nullable": true } } }, @@ -369,6 +373,10 @@ "type": "object", "additionalProperties": false, "properties": { + "whiteLabelKey": { + "type": "string", + "nullable": true + }, "language": { "type": "string", "nullable": true @@ -648,6 +656,10 @@ "type": "object", "additionalProperties": false, "properties": { + "whiteLabelKey": { + "type": "string", + "nullable": true + }, "userName": { "type": "string", "nullable": true @@ -699,6 +711,10 @@ "type": "object", "additionalProperties": false, "properties": { + "whiteLabelKey": { + "type": "string", + "nullable": true + }, "userName": { "type": "string", "nullable": true @@ -740,9 +756,6 @@ } }, "security": [ - { - "Bearer": [] - }, { "Bearer": [] } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj index 90238ff..508f2f0 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.5 + 0.0.0.6 client generated code. EasyMicroservices@gmail.com microservice,Identity,Identity,client diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Common/UserSummaryContract.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Common/UserSummaryContract.cs index b62904a..5e1f39a 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Common/UserSummaryContract.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Common/UserSummaryContract.cs @@ -8,6 +8,7 @@ namespace EasyMicroservices.IdentityMicroservice.Contracts.Common { public class UserSummaryContract { + public string WhiteLabelKey { get; set; } public string UserName { get; set; } public string Password { get; set; } } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/AddUserRequestContract.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/AddUserRequestContract.cs index d178dfa..674967b 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/AddUserRequestContract.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/AddUserRequestContract.cs @@ -13,5 +13,6 @@ public class AddUserRequestContract { public string UserName { get; set; } public string Password { get; set; } + public string WhiteLabelKey { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/ApplicationInitializeRequestContract.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/ApplicationInitializeRequestContract.cs index ebb0248..757c180 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/ApplicationInitializeRequestContract.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Requests/ApplicationInitializeRequestContract.cs @@ -8,6 +8,7 @@ namespace EasyMicroservices.IdentityMicroservice.Contracts.Common { public class ApplicationInitializeRequestContract { + public string WhiteLabelKey { get; set; } public string Language { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/EasyMicroservices.IdentityMicroservice.Domain.csproj b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/EasyMicroservices.IdentityMicroservice.Domain.csproj index 4f32eab..bb43585 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/EasyMicroservices.IdentityMicroservice.Domain.csproj +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/EasyMicroservices.IdentityMicroservice.Domain.csproj @@ -11,8 +11,7 @@ - - - + + diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/EasyMicroservices.IdentityMicroservice.Logics.csproj b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/EasyMicroservices.IdentityMicroservice.Logics.csproj index f3dbd51..82e3420 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/EasyMicroservices.IdentityMicroservice.Logics.csproj +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/EasyMicroservices.IdentityMicroservice.Logics.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/AppUnitOfWork.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/AppUnitOfWork.cs index 756702a..1bcfa38 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/AppUnitOfWork.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/AppUnitOfWork.cs @@ -9,8 +9,10 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System; +using System.Collections.Generic; +using System.Linq; using System.Net.Http; -using System.Text; +using WhiteLables.GeneratedServices; namespace EasyMicroservices.IdentityMicroservice.Helpers { @@ -41,10 +43,12 @@ public ClaimManager GetClaimManager() { return _service.GetService(); } - + static List ServiceAddresses; string GetValue(string key) { - return GetConfiguration().GetValue(key); + if (ServiceAddresses == null) + ServiceAddresses = GetConfiguration().GetSection("ServiceAddresses").Get>(); + return ServiceAddresses.FirstOrDefault(x => x.Name.Equals(key, StringComparison.OrdinalIgnoreCase)).Address; } public IHttpContextAccessor GetHttpContextAccessor() @@ -64,27 +68,32 @@ T InternalLogin(T client) public LanguageClient GetLanguageClient() { - return InternalLogin(new LanguageClient(GetValue("RootAddresses:Contents"), CurrentHttpClient)); + return InternalLogin(new LanguageClient(GetValue("Content"), CurrentHttpClient)); } public UserClient GetUserClient() { - return InternalLogin(new UserClient(GetValue("RootAddresses:Authentications"), CurrentHttpClient)); + return InternalLogin(new UserClient(GetValue("Authentication"), CurrentHttpClient)); } public RoleClient GetRoleClient() { - return InternalLogin(new RoleClient(GetValue("RootAddresses:Authentications"), CurrentHttpClient)); + return InternalLogin(new RoleClient(GetValue("Authentication"), CurrentHttpClient)); } public PersonalAccessTokenClient GetPersonalAccessTokenClientClient() { - return InternalLogin(new PersonalAccessTokenClient(GetValue("RootAddresses:Authentications"), CurrentHttpClient)); + return InternalLogin(new PersonalAccessTokenClient(GetValue("Authentication"), CurrentHttpClient)); } public ILoggerProvider GetLogger() { return ServiceProvider.GetService(); } + + public WhiteLabelClient GetWhiteLabelClient() + { + return InternalLogin(new WhiteLabelClient(GetValue("WhiteLabel"), CurrentHttpClient)); + } } } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/ClaimManager.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/ClaimManager.cs index 4f3ef00..dd5ebc1 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/ClaimManager.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/ClaimManager.cs @@ -1,4 +1,5 @@ using Authentications.GeneratedServices; +using EasyMicroservices.Cores.Interfaces; using EasyMicroservices.IdentityMicroservice.Contracts.Common; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; @@ -116,7 +117,7 @@ public List SetUniqueIdentity(string value, List c if (value != null) claims.Add(new ClaimContract { - Name = "UniqueIdentity", + Name = nameof(IUniqueIdentitySchema.UniqueIdentity), Value = value }); return claims; diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/IdentityHelper.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/IdentityHelper.cs index dc1843a..db16faa 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/IdentityHelper.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/IdentityHelper.cs @@ -1,14 +1,13 @@ -using Authentications.GeneratedServices; -using EasyMicroservices.IdentityMicroservice.Contracts.Common; +using EasyMicroservices.IdentityMicroservice.Contracts.Common; using EasyMicroservices.IdentityMicroservice.Contracts.Responses; using EasyMicroservices.IdentityMicroservice.Interfaces; using EasyMicroservices.ServiceContracts; using Microsoft.Extensions.Configuration; +using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using FailedReasonType = EasyMicroservices.ServiceContracts.FailedReasonType; namespace EasyMicroservices.IdentityMicroservice.Helpers { @@ -24,31 +23,46 @@ public IdentityHelper(IAppUnitOfWork appUnitOfWork) public async Task> Register(Contracts.Requests.AddUserRequestContract request) { - var client = _appUnitOfWork.GetUserClient(); - var usersRecords = await client.GetUserByUserNameAsync(new GetUserByUserNameRequestContract + var whiteLabelClient = _appUnitOfWork.GetWhiteLabelClient(); + var uniqueIdentityOfBusiness = await whiteLabelClient.GetUniqueIdentityByKeyAsync(new WhiteLables.GeneratedServices.GuidGetByIdRequestContract() { - Username = request.UserName.ToLower() + Id = System.Guid.Parse(request.WhiteLabelKey) }).AsCheckedResult(x => x.Result); - var user = await client.AddAsync(new AddUserRequestContract + var client = _appUnitOfWork.GetUserClient(); + var user = await client.GetUserByUserNameAsync(new Authentications.GeneratedServices.GetUserByUserNameRequestContract { - UserName = request.UserName, - Password = request.Password + UserName = request.UserName.ToLower(), + UniqueIdentity = uniqueIdentityOfBusiness }); + if (user.IsSuccess) + return (FailedReasonType.Duplicate, $"User with UserName: {request.UserName} already exists!"); + var addedUserId = await client.AddAsync(new Authentications.GeneratedServices.AddUserRequestContract + { + UserName = request.UserName, + Password = request.Password, + UniqueIdentity = uniqueIdentityOfBusiness + }).AsCheckedResult(x => x.Result); return new RegisterResponseContract { - UserId = user.Result, + UserId = addedUserId, }; } - public virtual async Task Login(Contracts.Common.UserSummaryContract cred) + public virtual async Task Login(Contracts.Common.UserSummaryContract request) { + var _whiteLabelClient = _appUnitOfWork.GetWhiteLabelClient(); + var uniqueIdentity = await _whiteLabelClient.GetUniqueIdentityByKeyAsync(new WhiteLables.GeneratedServices.GuidGetByIdRequestContract + { + Id = Guid.Parse(request.WhiteLabelKey) + }).AsCheckedResult(x => x.Result); var client = _appUnitOfWork.GetUserClient(); var user = await client.VerifyUserIdentityAsync(new Authentications.GeneratedServices.UserSummaryContract { - UserName = cred.UserName, - Password = cred.Password + UserName = request.UserName, + Password = request.Password, + UniqueIdentity = uniqueIdentity }).AsCheckedResult(x => x.Result); @@ -71,9 +85,10 @@ public async Task GetFullAccessPersonalAccessToken(string personalAccess Value = personalAccessToken }).AsCheckedResult(x => x.Result); - var roles = await _appUnitOfWork.GetRoleClient().GetRolesByUserIdAsync(new Authentications.GeneratedServices.Int64GetIdRequestContract + var roles = await _appUnitOfWork.GetRoleClient().GetRolesByUserIdAsync(new Authentications.GeneratedServices.GetByIdAndUniqueIdentityRequestContract { - Id = user.Id + Id = user.Id, + //UniqueIdentity = user.UniqueIdentity }).AsCheckedResult(x => x.Result); List claims = new(); diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/JWTManager.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/JWTManager.cs index 50c1c0e..ba29785 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/JWTManager.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Helpers/JWTManager.cs @@ -26,7 +26,7 @@ public class JWTManager : IJWTManager public JWTManager(IConfiguration config) { _config = config; - _authRoot = _config.GetValue("RootAddresses:Authentications"); + _authRoot = _config.GetValue("RootAddresses:Authentication"); _userClient = new(_authRoot, new System.Net.Http.HttpClient()); } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Interfaces/IAppUnitOfWork.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Interfaces/IAppUnitOfWork.cs index 074985b..ca528aa 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Interfaces/IAppUnitOfWork.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Logics/Interfaces/IAppUnitOfWork.cs @@ -11,6 +11,7 @@ using Authentications.GeneratedServices; using Contents.GeneratedServices; using EasyMicroservices.Logger.Interfaces; +using WhiteLables.GeneratedServices; namespace EasyMicroservices.IdentityMicroservice.Interfaces { @@ -26,5 +27,6 @@ public interface IAppUnitOfWork : IUnitOfWork public UserClient GetUserClient(); public RoleClient GetRoleClient(); public PersonalAccessTokenClient GetPersonalAccessTokenClientClient(); + public WhiteLabelClient GetWhiteLabelClient(); } } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.StartUp/DatabaseBuilder.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.StartUp/DatabaseBuilder.cs index 722566f..2bfbe89 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.StartUp/DatabaseBuilder.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.StartUp/DatabaseBuilder.cs @@ -1,21 +1,22 @@ -using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Intrerfaces; +using EasyMicroservices.Cores.Relational.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; namespace EasyMicroservices.IdentityMicroservice { - public class DatabaseBuilder : IEntityFrameworkCoreDatabaseBuilder + public class DatabaseBuilder : EntityFrameworkCoreDatabaseBuilder { - IConfiguration _configuration; - public DatabaseBuilder(IConfiguration configuration) + public DatabaseBuilder(IConfiguration configuration) : base(configuration) { - _configuration = configuration; } - public void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + public override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - //optionsBuilder.UseInMemoryDatabase("IdentityDatabase"); - optionsBuilder.UseSqlServer(_configuration.GetConnectionString("local")); + var entity = GetEntity(); + if (entity.IsSqlServer()) + optionsBuilder.UseSqlServer(entity.ConnectionString); + else if (entity.IsInMemory()) + optionsBuilder.UseInMemoryDatabase("Identity"); } } } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/AuthenticationController.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/AuthenticationController.cs index 7bccb88..bdfab4a 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/AuthenticationController.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/AuthenticationController.cs @@ -1,5 +1,4 @@ -using Authentications.GeneratedServices; -using Contents.GeneratedServices; +using Contents.GeneratedServices; using EasyMicroservices.IdentityMicroservice.Attributes; using EasyMicroservices.IdentityMicroservice.Contracts.Common; using EasyMicroservices.IdentityMicroservice.Contracts.Requests; @@ -9,13 +8,13 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Security.Claims; +using System.Text; namespace EasyMicroservices.IdentityMicroservice.WebApi.Controllers { [ApiController] [Route("api/[controller]/[action]")] - [AllowAnonymous] public class AuthenticationController : ControllerBase { private readonly IAppUnitOfWork _appUnitOfWork; @@ -46,7 +45,10 @@ private void SetCookie(string key, string value) public async Task VerifyUserName(VerifyUserRequestContract request) { var _userClient = _appUnitOfWork.GetUserClient(); - var user = await _userClient.GetByIdAsync(new Authentications.GeneratedServices.Int64GetIdRequestContract { Id = request.UserId }); + var user = await _userClient.GetByIdAsync(new Authentications.GeneratedServices.Int64GetByIdRequestContract + { + Id = request.UserId + }); if (!user.IsSuccess) return (ServiceContracts.FailedReasonType.NotFound, "User not found"); @@ -71,6 +73,7 @@ await _userClient.UpdateAsync(new Authentications.GeneratedServices.UserContract } [HttpPost] + [AllowAnonymous] public async Task> Register(Contracts.Requests.AddUserRequestContract request) { var _identityHelper = _appUnitOfWork.GetIdentityHelper(); @@ -78,19 +81,24 @@ public async Task> Register(Contracts. } [HttpPost] + [AllowAnonymous] public async Task> Login(Contracts.Common.UserSummaryContract request) { var _identityHelper = _appUnitOfWork.GetIdentityHelper(); var response = await _identityHelper.Login(request); var user = await _appUnitOfWork.GetUserClient() - .GetByIdAsync(new Authentications.GeneratedServices.Int64GetIdRequestContract { Id = response.UserId }) + .GetByIdAsync(new Authentications.GeneratedServices.Int64GetByIdRequestContract + { + Id = response.UserId + }) .AsCheckedResult(x => x.Result); var roles = await _appUnitOfWork.GetRoleClient() - .GetRolesByUserIdAsync(new Authentications.GeneratedServices.Int64GetIdRequestContract + .GetRolesByUserIdAsync(new Authentications.GeneratedServices.GetByIdAndUniqueIdentityRequestContract { - Id = response.UserId + Id = response.UserId, + //UniqueIdentity = uniqueIdentity }).AsCheckedResult(x => x.Result); List claims = new(); @@ -107,20 +115,20 @@ public async Task> Login(Contrac Value = x.Name }).ToList(), claims); } + var tokenResponse = await _appUnitOfWork.GetIJWTManager().GenerateTokenWithClaims(claims); - var TokenResponse = await _appUnitOfWork.GetIJWTManager().GenerateTokenWithClaims(claims); - - SetCookie("token", TokenResponse.Result.Token); + SetCookie("token", tokenResponse.Result.Token); return new LoginWithTokenResponseContract { UserId = response.UserId, - Token = TokenResponse.Result.Token + Token = tokenResponse.Result.Token }; } [HttpPost] [ApplicationInitializeCheck] + [AllowAnonymous] public async Task> GenerateToken(UserClaimContract request) { request.Claims = request.Claims.Where(x => !x.Name.Contains("Role", StringComparison.OrdinalIgnoreCase)).ToList(); @@ -132,6 +140,7 @@ public async Task> GenerateToken(UserClaim [HttpPost] [CustomAuthorizeCheck] + [AllowAnonymous] public async Task> RegenerateToken(RegenerateTokenContract request) { request.Claims = request.Claims.Where(x => !x.Name.Contains("Role", StringComparison.OrdinalIgnoreCase)).ToList(); @@ -140,7 +149,7 @@ public async Task> RegenerateToken(Regener _userClient.SetBearerToken(_appUnitOfWork.GetConfiguration().GetValue("Authorization:FullAccessPAT")); var _claimManager = _appUnitOfWork.GetClaimManager(); - var user = await _userClient.GetByIdAsync(new Authentications.GeneratedServices.Int64GetIdRequestContract + var user = await _userClient.GetByIdAsync(new Authentications.GeneratedServices.Int64GetByIdRequestContract { Id = _claimManager.Id }); @@ -170,17 +179,15 @@ public async Task> RegenerateToken(Regener } [HttpPost] + [AllowAnonymous] public async Task> ApplicationInitialize(ApplicationInitializeRequestContract request) { LanguageClient _languageClient = _appUnitOfWork.GetLanguageClient(); - var language = await _languageClient.HasLanguageAsync(new HasLanguageRequestContract + await _languageClient.HasLanguageAsync(new HasLanguageRequestContract { Language = request.Language - }); - - if (!language.IsSuccess) - return (ServiceContracts.FailedReasonType.NotFound, "Language not found."); + }).AsCheckedResult(); List claims = new(); var _claimManager = _appUnitOfWork.GetClaimManager(); @@ -188,17 +195,30 @@ public async Task> Applic if (_claimManager.HasId()) { _claimManager.SetId(_claimManager.Id, claims); - _claimManager.SetRole(_claimManager.Role.Select(o => new ClaimContract() { Name = ClaimTypes.Name, Value = o }).ToList(), claims); + _claimManager.SetRole(_claimManager.Role.Select(o => new ClaimContract() + { + Name = ClaimTypes.Name, + Value = o + }).ToList(), claims); } + if (request.WhiteLabelKey.HasValue()) + { + var _whiteLabelClient = _appUnitOfWork.GetWhiteLabelClient(); + var uniqueIdentity = await _whiteLabelClient.GetUniqueIdentityByKeyAsync(new WhiteLables.GeneratedServices.GuidGetByIdRequestContract + { + Id = Guid.Parse(request.WhiteLabelKey) + }).AsCheckedResult(x => x.Result); + _claimManager.SetUniqueIdentity(uniqueIdentity, claims); + } + var tokenResponse = await _appUnitOfWork.GetIJWTManager().GenerateTokenWithClaims(claims); - var TokenResponse = await _appUnitOfWork.GetIJWTManager().GenerateTokenWithClaims(claims); - - SetCookie("token", TokenResponse.Result.Token); + SetCookie("token", tokenResponse.Result.Token); - return new ApplicationInitializeResponseContract() { IsLogin = _claimManager.HasId(), Token = TokenResponse.Result.Token }; + return new ApplicationInitializeResponseContract() { IsLogin = _claimManager.HasId(), Token = tokenResponse.Result.Token }; } [HttpPost] + [AllowAnonymous] public async Task> LoginByPersonalAccessToken(LoginByPersonalAccessTokenRequestContract request) { var token = await _appUnitOfWork.GetIdentityHelper().GetFullAccessPersonalAccessToken(request.PersonalAccessToken); diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/EasyMicroservices.IdentityMicroservice.WebApi.csproj b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/EasyMicroservices.IdentityMicroservice.WebApi.csproj index 8d7fc02..98f504a 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/EasyMicroservices.IdentityMicroservice.WebApi.csproj +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/EasyMicroservices.IdentityMicroservice.WebApi.csproj @@ -6,8 +6,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Program.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Program.cs index f10ef86..3f458cd 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Program.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Program.cs @@ -34,7 +34,7 @@ static WebApplicationBuilder CreateBuilder(string[] args) .MinimumLevel.Is(Serilog.Events.LogEventLevel.Verbose)); }); - app.Services.Builder().UseDefaultSwaggerOptions(); + app.Services.Builder("Identity").UseDefaultSwaggerOptions(); app.Services.AddTransient((serviceProvider) => new UnitOfWork(serviceProvider)); app.Services.AddTransient(serviceProvider => new IdentityContext(serviceProvider.GetService())); app.Services.AddTransient(); @@ -43,8 +43,6 @@ static WebApplicationBuilder CreateBuilder(string[] args) app.Services.AddTransient(); app.Services.AddTransient(); app.Services.AddHostedService(); - - StartUpExtensions.AddWhiteLabel("Identity", "RootAddresses:WhiteLabel"); return app; } diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.Development.json b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.Development.json index 6b8c107..4b83671 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.Development.json +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.Development.json @@ -6,15 +6,30 @@ } }, "AllowedHosts": "*", - "ConnectionStrings": { - "local": "Server=.;Database=Identity;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" - }, - "RootAddresses": { - "WhiteLabel": "http://localhost:1041", - "Authentications": "http://localhost:1044", - "Contents": "http://localhost:2003" - }, - + "Databases": [ + { + "Name": "Entity", + "ProviderName": "InMemory", + "ConnectionString": "Server=.;Database=Identity;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" + } + ], + "ServiceAddresses": [ + { + "Name": "Authentication", + "Address": "http://localhost:1044", + "Databases": null + }, + { + "Name": "WhiteLabel", + "Address": "http://localhost:1041", + "Databases": null + }, + { + "Name": "Content", + "Address": "http://localhost:2003", + "Databases": null + } + ], "Authorization": { "Use": true, "JWT": { @@ -24,7 +39,7 @@ "TokenExpireTimeInSeconds": 86400 }, - "FullAccessPAT": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjEiLCJyb2xlIjoiT3duZXIiLCJuYmYiOjE3MDEyNjQ4MTQsImV4cCI6MTcwMTM1MTIxNCwiaWF0IjoxNzAxMjY0ODE0LCJpc3MiOiJodHRwczovL2dpdGh1Yi5jb20vZWFzeW1pY3Jvc2VydmljZXMiLCJhdWQiOiJlYXN5bWljcm9zZXJ2aWNlcyJ9.CcfO9sXz3PY_QED7MwHe0-UJc_We_1NihDkAGonIsUs" + "FullAccessPAT": "ownerpat" }, "HasSSL": false, diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.json b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.json index 6b8c107..4b83671 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.json +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/appsettings.json @@ -6,15 +6,30 @@ } }, "AllowedHosts": "*", - "ConnectionStrings": { - "local": "Server=.;Database=Identity;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" - }, - "RootAddresses": { - "WhiteLabel": "http://localhost:1041", - "Authentications": "http://localhost:1044", - "Contents": "http://localhost:2003" - }, - + "Databases": [ + { + "Name": "Entity", + "ProviderName": "InMemory", + "ConnectionString": "Server=.;Database=Identity;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" + } + ], + "ServiceAddresses": [ + { + "Name": "Authentication", + "Address": "http://localhost:1044", + "Databases": null + }, + { + "Name": "WhiteLabel", + "Address": "http://localhost:1041", + "Databases": null + }, + { + "Name": "Content", + "Address": "http://localhost:2003", + "Databases": null + } + ], "Authorization": { "Use": true, "JWT": { @@ -24,7 +39,7 @@ "TokenExpireTimeInSeconds": 86400 }, - "FullAccessPAT": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjEiLCJyb2xlIjoiT3duZXIiLCJuYmYiOjE3MDEyNjQ4MTQsImV4cCI6MTcwMTM1MTIxNCwiaWF0IjoxNzAxMjY0ODE0LCJpc3MiOiJodHRwczovL2dpdGh1Yi5jb20vZWFzeW1pY3Jvc2VydmljZXMiLCJhdWQiOiJlYXN5bWljcm9zZXJ2aWNlcyJ9.CcfO9sXz3PY_QED7MwHe0-UJc_We_1NihDkAGonIsUs" + "FullAccessPAT": "ownerpat" }, "HasSSL": false, diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/serilog.txt b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/serilog.txt new file mode 100644 index 0000000..2aea86c --- /dev/null +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/serilog.txt @@ -0,0 +1,123 @@ +2023-12-24 23:25:35.512 +03:30 [DBG] Try login... +2023-12-24 23:25:37.460 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-24 23:29:47.211 +03:30 [DBG] Try login... +2023-12-24 23:29:47.831 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-24 23:30:00.288 +03:30 [DBG] Try login... +2023-12-24 23:30:00.740 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-25 09:23:33.812 +03:30 [DBG] Try login... +2023-12-25 09:23:34.496 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-26 19:23:34.795 +03:30 [DBG] Try login... +2023-12-26 19:23:52.372 +03:30 [DBG] Try login... +2023-12-26 19:24:33.990 +03:30 [DBG] Try login... +2023-12-26 19:25:06.481 +03:30 [DBG] Try login... +2023-12-26 19:25:07.965 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-26 19:38:34.986 +03:30 [DBG] Try login... +2023-12-26 19:38:35.399 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-26 19:42:07.241 +03:30 [DBG] Try login... +2023-12-26 19:42:07.634 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-26 19:47:14.974 +03:30 [DBG] Try login... +2023-12-26 19:47:15.900 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 69 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-26 21:07:52.200 +03:30 [DBG] Try login... +2023-12-26 21:07:56.740 +03:30 [ERR] Empty +System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (localhost:1044) + ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it. + at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) + at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) + at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) + at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) + --- End of inner exception stack trace --- + at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) + at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) + at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) + at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem) + at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken) + at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken) + at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) + at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) + at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) + at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) + at Authentications.GeneratedServices.UserClient.GetUserByPersonalAccessTokenAsync(PersonalAccessTokenRequestContract body, CancellationToken cancellationToken) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 76 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-27 12:46:02.258 +03:30 [DBG] Try login... +2023-12-27 12:46:03.405 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 76 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-27 12:50:03.975 +03:30 [DBG] Try login... +2023-12-27 12:50:18.983 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 76 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-27 12:50:35.795 +03:30 [DBG] Try login... +2023-12-27 12:51:13.304 +03:30 [DBG] Try login... +2023-12-27 12:51:20.998 +03:30 [ERR] Empty +EasyMicroservices.ServiceContracts.Exceptions.InvalidResultOfMessageContractException: The MessageContract is not success, Summary: Item by predicate not found! + at EasyMicroservices.ServiceContracts.MessageContract.ThrowsIfFails() + at EasyMicroservices.ServiceContracts.MessageContractExtensions.ThrowsIfFails(Object result) + at EasyMicroservices.ServiceContracts.MessageContractExtensions.AsCheckedResult[T,T2](Task`1 task, Func`2 mapResult) + at EasyMicroservices.IdentityMicroservice.Helpers.IdentityHelper.GetFullAccessPersonalAccessToken(String personalAccessToken) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\Helpers\IdentityHelper.cs:line 76 + at EasyMicroservices.IdentityMicroservice.BackgroundServices.InternalTokenGeneratorBackgroundService.GetToken(IAppUnitOfWork appUnitOfWork) in D:\Github\EasyMicroservices\Microservices\Identity\src\CSharp\EasyMicroservices.IdentityMicroservice.Logics\BackgroundServices\InternalTokenGeneratorBackgroundService.cs:line 37 +2023-12-27 12:51:23.766 +03:30 [DBG] Try login... +2023-12-27 12:51:59.481 +03:30 [DBG] Try login... +2023-12-27 12:55:19.792 +03:30 [DBG] Try login... +2023-12-27 12:55:24.221 +03:30 [DBG] Login success eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjEiLCJVbmlxdWVJZGVudGl0eSI6IjEtMiIsInJvbGUiOiJPd25lciIsIm5iZiI6MTcwMzY2OTEyMCwiZXhwIjoxNzAzNzU1NTIwLCJpYXQiOjE3MDM2NjkxMjAsImlzcyI6Imh0dHBzOi8vZ2l0aHViLmNvbS9lYXN5bWljcm9zZXJ2aWNlcyIsImF1ZCI6ImVhc3ltaWNyb3NlcnZpY2VzIn0.dGmzIFraAlcYSEXY6zc14lY3Ivk1yX6siAObnV2EAr8 +2023-12-27 12:58:51.087 +03:30 [DBG] Try login... +2023-12-27 12:58:51.577 +03:30 [DBG] Login success eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjEiLCJVbmlxdWVJZGVudGl0eSI6IjEtMiIsInJvbGUiOiJPd25lciIsIm5iZiI6MTcwMzY2OTMzMSwiZXhwIjoxNzAzNzU1NzMxLCJpYXQiOjE3MDM2NjkzMzEsImlzcyI6Imh0dHBzOi8vZ2l0aHViLmNvbS9lYXN5bWljcm9zZXJ2aWNlcyIsImF1ZCI6ImVhc3ltaWNyb3NlcnZpY2VzIn0.CpgUWOam3lLfK37JMs_mFxecdKioivXA4L19Pf9PCik +2023-12-29 12:52:17.107 +03:30 [DBG] Try login... +2023-12-29 12:52:18.377 +03:30 [DBG] Login success eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjEiLCJVbmlxdWVJZGVudGl0eSI6IjEtMiIsInJvbGUiOiJPd25lciIsIm5iZiI6MTcwMzg0MTczOCwiZXhwIjoxNzAzOTI4MTM4LCJpYXQiOjE3MDM4NDE3MzgsImlzcyI6Imh0dHBzOi8vZ2l0aHViLmNvbS9lYXN5bWljcm9zZXJ2aWNlcyIsImF1ZCI6ImVhc3ltaWNyb3NlcnZpY2VzIn0.wNe0EYwpxeXn1iLyWISLa6B8o_FD-rYjR-DBF4glQqw