Configura authentication and authorization
This commit is contained in:
		| @@ -3,6 +3,7 @@ using Core.Thalos.Adapters; | ||||
| using Core.Thalos.Adapters.Common.Constants; | ||||
| using Core.Thalos.Adapters.Contracts; | ||||
| using Core.Thalos.Application.UseCases.Users.Input; | ||||
| using Core.Thalos.BuildingBlocks.Authentication.Authorization.Google; | ||||
| using Core.Thalos.External.Clients.Thalos.Requests.Users; | ||||
| using LSA.Dashboard.External.Clients.Dashboard; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| @@ -18,8 +19,22 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     [Produces(MimeTypes.ApplicationJson)] | ||||
|     [Consumes(MimeTypes.ApplicationJson)] | ||||
|     [ApiController] | ||||
|     public class AuthenticationController(IThalosServiceClient thalosServiceClient, ILogger<AuthenticationController> logger, ITokenService tokenService) : BaseController(logger) | ||||
|     public class AuthenticationController( | ||||
|     IThalosServiceClient thalosServiceClient, | ||||
|     ILogger<AuthenticationController> logger, | ||||
|     ITokenService tokenService, | ||||
|     IGoogleAuthorization googleAuthorization) : BaseController(logger) | ||||
|     { | ||||
|         [HttpGet] | ||||
|         public IActionResult Authorize() => Ok(googleAuthorization.GetAuthorizationUrl()); | ||||
|  | ||||
|         [HttpGet("callback")] | ||||
|         public async Task<IActionResult> Callback(string code) | ||||
|         { | ||||
|             var userCredential = await googleAuthorization.ExchangeCodeForToken(code); | ||||
|  | ||||
|             return Ok(new { Token = userCredential!.Token.IdToken }); | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// Get token for user. | ||||
|         /// </summary> | ||||
| @@ -30,7 +45,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [HttpGet] | ||||
|         [Route(Routes.GenerateToken)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.AzureScheme)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.GoogleScheme)] | ||||
|         public async Task<IActionResult> GenerateTokenService(CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales