aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-13 23:09:44 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-13 23:09:44 +0200
commit678b22afc27e53811f978103b7ea41609ff68606 (patch)
treefaaabb6468c1b22d770eb753eeac39b34ef65e4f /Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs
parent69f27fd4bfc5a46fad019b06c9c8d06159c400b9 (diff)
downloadTango-678b22afc27e53811f978103b7ea41609ff68606.tar.gz
Tango-678b22afc27e53811f978103b7ea41609ff68606.zip
Implemented and deployed machine service gateway.
Implemented AzureUtils => Gateway.
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.cs23
1 files changed, 10 insertions, 13 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
index 2daf3c7e6..ae5aa4543 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/AzureUtilsController.cs
@@ -3,10 +3,12 @@ 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.MachineService.Gateway.Messages;
using Tango.Web.Controllers;
using Tango.Web.Security;
@@ -20,43 +22,38 @@ namespace Tango.MachineService.Gateway.Controllers
}
[HttpPost]
- public LoginResponse Login(LoginRequest request)
+ public async Task<LoginResponse> Login(LoginRequest request)
{
- var azure = AzureUtils.AzureUtilsAuthenticationFactory.AuthenticateOrGetAsync().Result;
+ var azure = await AzureUtils.AzureUtilsAuthenticationFactory.AuthenticateOrGetAsync();
AzureUtils.ActiveDirectory.ActiveDirectoryManager adManager = new AzureUtils.ActiveDirectory.ActiveDirectoryManager(azure);
try
{
- adManager.Authenticate(request.Email, request.Password).GetAwaiter().GetResult();
+ await adManager.Authenticate(request.Email, request.Password);
}
catch (Exception ex)
{
throw new AuthenticationException("The specified email or password is incorrect.", ex);
}
- try
- {
- adManager.IsUserMemberOf(MachineServiceGatewayConfig.AZURE_UTILS_GROUP, request.Email);
- }
- catch
+ 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(MachineServiceGatewayConfig.JWT_TOKEN_SECRET, new TokenObject()
+ AccessToken = WebToken<TokenObject>.CreateNew(GatewayConfig.JWT_TOKEN_SECRET, new TokenObject()
{
Email = request.Email,
}, DateTime.UtcNow.AddDays(1)).AccessToken,
};
}
- [HttpPost]
[JwtTokenFilter]
- public void DoSomethingSecret()
+ public AzureUtilsCredentials GetCredentials()
{
-
+ return AzureUtils.AzureUtilsAuthenticationFactory.GetGlobalCredentials();
}
}
} \ No newline at end of file