Compare commits
	
		
			5 Commits
		
	
	
		
			feature/te
			...
			3b752f182f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3b752f182f | |||
| 4a2ed52a2f | |||
| 5277896bdc | |||
| 9a02f0e4d6 | |||
| 035da054d6 | 
| @@ -96,5 +96,13 @@ namespace Core.Thalos.BuildingBlocks | ||||
|         [BsonRepresentation(BsonType.String)] | ||||
|         [JsonPropertyName("token")] | ||||
|         public string? Token { get; set; } = null; | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets or sets the tenant identifier associated with the user. | ||||
|         /// </summary> | ||||
|         [BsonElement("tenantId")] | ||||
|         [BsonRepresentation(BsonType.ObjectId)] | ||||
|         [JsonPropertyName("tenantId")] | ||||
|         public string? TenantId { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -5,9 +5,9 @@ using Microsoft.Extensions.Configuration; | ||||
| namespace Core.Thalos.BuildingBlocks | ||||
| { | ||||
|     public class GoogleAuthorization( | ||||
|         IGoogleAuthHelper googleHelper, IConfiguration config) : IGoogleAuthorization | ||||
|         IGoogleAuthHelper googleHelper, IConfiguration config, GoogleAuthSettings googlesettings) : IGoogleAuthorization | ||||
|     { | ||||
|         private string RedirectUrl = config["Authentication:Google:RedirectUri"]!; | ||||
|         private string RedirectUrl = googlesettings.RedirectUri ?? string.Empty; | ||||
|  | ||||
|         public async Task<UserCredential> ExchangeCodeForToken(string code) | ||||
|         { | ||||
|   | ||||
| @@ -74,7 +74,7 @@ namespace Core.Thalos.BuildingBlocks | ||||
|         /// <summary> | ||||
|         /// The ChangeStatus route. | ||||
|         /// </summary> | ||||
|         public const string ChangeStatus = "{id}/{newStatus}/ChangeStatus"; | ||||
|         public const string ChangeStatus = "{_id}/{newStatus}/ChangeStatus"; | ||||
|  | ||||
|         /// <summary> | ||||
|         /// The AddCompany route. | ||||
|   | ||||
| @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Microsoft.Extensions.Options; | ||||
| using Microsoft.Identity.Web; | ||||
| using Microsoft.IdentityModel.Tokens; | ||||
| using System.Security.Cryptography; | ||||
| @@ -87,8 +86,6 @@ namespace Core.Thalos.BuildingBlocks.Configuration | ||||
|                 options.Audience = jwtIssuerOptions?.Audience; | ||||
|                 options.SigningCredentials = new SigningCredentials(rsaPrivateKey, SecurityAlgorithms.RsaSha256); | ||||
|             }); | ||||
|  | ||||
|             services.AddSingleton<IOptions<JwtIssuerOptions>>(Microsoft.Extensions.Options.Options.Create(jwtIssuerOptions)); | ||||
|         } | ||||
|  | ||||
|         public static void AddAzureAuthentication(AuthSettings authSettings, IConfiguration configuration, IServiceCollection services) | ||||
| @@ -116,6 +113,8 @@ namespace Core.Thalos.BuildingBlocks.Configuration | ||||
|  | ||||
|         public static void AddGoogleAuthentication(IServiceCollection services, GoogleAuthSettings googleAuthSettings) | ||||
|         { | ||||
|             services.AddSingleton<GoogleAuthSettings>(googleAuthSettings); | ||||
|  | ||||
|             services.AddAuthentication(options => | ||||
|             { | ||||
|                 options.DefaultAuthenticateScheme = Schemes.GoogleScheme; | ||||
|   | ||||
| @@ -11,7 +11,10 @@ namespace Core.Thalos.BuildingBlocks | ||||
|     public class GoogleAccessTokenAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, | ||||
|          ILoggerFactory logger, | ||||
|          UrlEncoder encoder, | ||||
|          IConfiguration config) : AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder) | ||||
|          IConfiguration config, | ||||
|          GoogleAuthSettings googleSettings | ||||
|          ) : AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder) | ||||
|  | ||||
|     { | ||||
|         protected override async Task<AuthenticateResult> HandleAuthenticateAsync() | ||||
|         { | ||||
| @@ -31,7 +34,7 @@ namespace Core.Thalos.BuildingBlocks | ||||
|                     idToken, | ||||
|                     new GoogleJsonWebSignature.ValidationSettings | ||||
|                     { | ||||
|                         Audience = new[] { config["Authentication:Google:ClientId"]! } | ||||
|                         Audience = new[] { googleSettings.ClientId! } | ||||
|                     }); | ||||
|             } | ||||
|             catch (InvalidJwtException) | ||||
|   | ||||
| @@ -4,12 +4,12 @@ using Microsoft.Extensions.Configuration; | ||||
|  | ||||
| namespace Core.Thalos.BuildingBlocks | ||||
| { | ||||
|     public class GoogleAuthHelper(IConfiguration config) : IGoogleAuthHelper | ||||
|     public class GoogleAuthHelper(IConfiguration config, GoogleAuthSettings googleSettings) : IGoogleAuthHelper | ||||
|     { | ||||
|         public ClientSecrets GetClientSecrets() | ||||
|         { | ||||
|             string clientId = config["Authentication:Google:ClientId"]!; | ||||
|             string clientSecret = config["Authentication:Google:ClientSecret"]!; | ||||
|             string clientId = googleSettings.ClientId ?? string.Empty; | ||||
|             string clientSecret = googleSettings.ClientSecret ?? string.Empty; | ||||
|  | ||||
|             return new() { ClientId = clientId, ClientSecret = clientSecret }; | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user