Add google authentication
This commit is contained in:
		| @@ -3,10 +3,16 @@ 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.BFF.Api.Services; | ||||
| using Core.Thalos.External.Clients.Thalos.Requests.Users; | ||||
| using Google.Apis.Auth.OAuth2; | ||||
| using LSA.Dashboard.External.Clients.Dashboard; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Microsoft.Graph; | ||||
| using Newtonsoft.Json.Linq; | ||||
| using System.Reflection; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Core.Thalos.BFF.Api.Controllers | ||||
| { | ||||
| @@ -18,8 +24,23 @@ 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 +51,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [HttpGet] | ||||
|         [Route(Routes.GenerateToken)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.AzureScheme)] | ||||
|         [Authorize] | ||||
|         public async Task<IActionResult> GenerateTokenService(CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales