aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs59
1 files changed, 0 insertions, 59 deletions
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<AzureUtilsController.TokenObject>
- {
- public class TokenObject
- {
- public String Email { get; set; }
- }
-
- [HttpPost]
- public async Task<LoginResponse> 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<TokenObject>.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