diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-12-23 12:44:08 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-12-23 12:44:08 +0200 |
| commit | 4e496467dcc8549605917a44263d78cef40f71bb (patch) | |
| tree | 3e385e90ec94c5f7d590aaa71991b40fcc05df67 /Software/Visual_Studio/MachineStudio | |
| parent | 5cb09f7732429d15477321e7f748d010ef27c85d (diff) | |
| download | Tango-4e496467dcc8549605917a44263d78cef40f71bb.tar.gz Tango-4e496467dcc8549605917a44263d78cef40f71bb.zip | |
Implemented machine studio active directory secure login.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
5 files changed, 32 insertions, 17 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index cab3d2bfc..1d3660c5f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -39,10 +39,8 @@ namespace Tango.MachineStudio.Common public String LastVirtualMachineSerialNumber { get; set; } /// <summary> - /// Gets or sets the update service address. + /// Gets or sets the machine service address. /// </summary> - public String UpdateServiceAddress { get; set; } - public String MachineServiceAddress { get; set; } /// <summary> @@ -97,7 +95,6 @@ namespace Tango.MachineStudio.Common { LastBounds = new Rect(); LoggingCategories = new List<LogCategory>(); - UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; MachineServiceAddress = "http://machineservice.twine-srv.com/"; DefaultIssueReportTags = new List<string>(); StudioModulesBounds = new List<StudioModuleBounds>(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index ca4d95805..cd99b00d0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -127,7 +127,7 @@ <Compile Include="Update\LatestVersionRequest.cs" /> <Compile Include="Update\LatestVersionResponse.cs" /> <Compile Include="Update\MachineStudioUpdateService.cs" /> - <Compile Include="Update\UpdateServiceHelper.cs" /> + <None Include="Update\UpdateServiceHelper.cs" /> <Compile Include="Update\UploadCompletedRequest.cs" /> <Compile Include="Update\UploadCompletedResponse.cs" /> <Compile Include="Update\UploadVersionRequest.cs" /> @@ -310,7 +310,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index fd68ed8d1..3293dab3f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -10,6 +10,9 @@ using Tango.MachineStudio.Common.Authentication; using Tango.BL; using Tango.BL.Enumerations; using System.Data.Entity; +using Tango.Transport.Web; +using Tango.Settings; +using Tango.MachineStudio.Common; namespace Tango.MachineStudio.UI.Authentication { @@ -49,11 +52,21 @@ namespace Tango.MachineStudio.UI.Authentication /// <exception cref="AuthenticationException">Login failed for user " + email</exception> public User Login(string email, string password) { - using (ObservablesContext db = ObservablesContext.CreateDefault()) + var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); + + IWebTransportClient service = new WebTransportClient(); + var response = service.PostJson<LoginRequest, LoginResponse>(settings.MachineServiceAddress + "/api/MachineStudio/Login", new LoginRequest() { - String hash = User.GetPasswordHash(password); + Email = email, + Password = password, + + }).Result; + ObservablesContext.OverrideSettingsDataSource(response.DataSource); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { db.Roles.Load(); db.Permissions.Load(); db.RolesPermissions.Load(); @@ -62,7 +75,7 @@ namespace Tango.MachineStudio.UI.Authentication .Include(x => x.UsersRoles) .Include(x => x.Contact) .Include(x => x.Address) - .Include(x => x.Organization).SingleOrDefault(x => x.Email.ToLower() == email.ToLower() && x.Password == hash); + .Include(x => x.Organization).SingleOrDefault(x => x.Email.ToLower() == email.ToLower()); if (user == null) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 545d51ef2..6e8d0488b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -144,9 +144,8 @@ namespace Tango.MachineStudio.UI.ViewModels Status = "Loading, please wait..."; - ObservablesStaticCollections.Instance.Initialize(); - - _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + //ObservablesStaticCollections.Instance.Initialize(); + //_eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); Status = "Starting application..."; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index a37879a5e..4e659d46a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -6,6 +6,8 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.Core.Cryptography; using Tango.MachineStudio.Common; @@ -90,7 +92,7 @@ namespace Tango.MachineStudio.UI.ViewModels _navigationManager = navigationManager; _authenticationProvider = authenticationProvider; _eventLogger = eventLogger; - LoginCommand = new RelayCommand(Login,() => !IsLogging); + LoginCommand = new RelayCommand(Login, () => !IsLogging); cryptographer = new Rfc2898Cryptographer(); Email = _settings.LastLoginEmail; @@ -121,6 +123,10 @@ namespace Tango.MachineStudio.UI.ViewModels await Task.Factory.StartNew(() => { _authenticationProvider.Login(Email, Password); + + ObservablesStaticCollections.Instance.Initialize(); + _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + _navigationManager.NavigateTo(NavigationView.MainView); _settings.LastLoginEmail = Email; _settings.RememberMe = RememberMe; @@ -128,13 +134,13 @@ namespace Tango.MachineStudio.UI.ViewModels _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null; _settings.Save(); - _eventLogger.Log("User logged in"); + _eventLogger.Log("User logged in."); }); } - catch (Exception) + catch (Exception ex) { - - _notificationProvider.ShowError("Invalid credentials. Please try again."); + LogManager.Log(ex, "Login Error."); + _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.Message}"); } finally { |
