From 00a491d93733d4625ad329b2ba8237f445364b3f Mon Sep 17 00:00:00 2001 From: Mirta Date: Wed, 30 Dec 2020 16:39:52 +0200 Subject: merge --- .../Controllers/AzureUtilsController.cs | 59 ---------------------- 1 file changed, 59 deletions(-) delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs (limited to 'Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs') diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs deleted file mode 100644 index ae5aa4543..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.IdentityModel.Clients.ActiveDirectory; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Authentication; -using System.Threading.Tasks; -using System.Web; -using System.Web.Mvc; -using Tango.AzureUtils; -using Tango.AzureUtils.Web; -using Tango.MachineService.Gateway.Filters; -using Tango.Web.Controllers; -using Tango.Web.Security; - -namespace Tango.MachineService.Gateway.Controllers -{ - public class AzureUtilsController : TangoController - { - public class TokenObject - { - public String Email { get; set; } - } - - [HttpPost] - public async Task Login(LoginRequest request) - { - var azure = await AzureUtils.AzureUtilsAuthenticationFactory.AuthenticateOrGetAsync(); - AzureUtils.ActiveDirectory.ActiveDirectoryManager adManager = new AzureUtils.ActiveDirectory.ActiveDirectoryManager(azure); - - try - { - await adManager.Authenticate(request.Email, request.Password); - } - catch (Exception ex) - { - throw new AuthenticationException("The specified email or password is incorrect.", ex); - } - - if (!adManager.IsUserMemberOf(GatewayConfig.AZURE_UTILS_GROUP, request.Email)) - { - throw new AuthenticationException("The specified user is not authorized to access the resource."); - } - - return new LoginResponse() - { - AccessToken = WebToken.CreateNew(GatewayConfig.JWT_TOKEN_SECRET, new TokenObject() - { - Email = request.Email, - }, DateTime.UtcNow.AddDays(1)).AccessToken, - }; - } - - [JwtTokenFilter] - public AzureUtilsCredentials GetCredentials() - { - return AzureUtils.AzureUtilsAuthenticationFactory.GetGlobalCredentials(); - } - } -} \ No newline at end of file -- cgit v1.3.1