aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Software/DB/Tango.mdfbin75497472 -> 75497472 bytes
-rw-r--r--Software/DB/Tango_log.ldfbin20578304 -> 20578304 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs5
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs4
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs7
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs42
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs5
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs3
-rw-r--r--Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs30
-rw-r--r--Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs2
-rw-r--r--Software/Visual_Studio/Tango.Web/Tango.Web.csproj1
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs22
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Web.config2
15 files changed, 58 insertions, 68 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf
index 978deab2f..3068c20a8 100644
--- a/Software/DB/Tango.mdf
+++ b/Software/DB/Tango.mdf
Binary files differ
diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf
index 30de45e33..315369a3f 100644
--- a/Software/DB/Tango_log.ldf
+++ b/Software/DB/Tango_log.ldf
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs
index 0c2aa3cb7..785dc1523 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs
@@ -13,6 +13,11 @@ namespace Tango.MachineStudio.Common.Authentication
public interface IAuthenticationProvider
{
/// <summary>
+ /// Gets the access token that was retrieved at the last login.
+ /// </summary>
+ String AccessToken { get; }
+
+ /// <summary>
/// Occurs when the current logged-in user has changed.
/// </summary>
event EventHandler<User> CurrentUserChanged;
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs
index 075a5ec10..3da033b9f 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs
@@ -11,5 +11,6 @@ namespace Tango.MachineStudio.Common.Authentication
public class LoginResponse : WebResponseMessage
{
public DataSource DataSource { get; set; }
+ public String Token { get; set; }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs
index 11911dd7e..cf06e678d 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs
@@ -10,9 +10,7 @@ namespace Tango.MachineStudio.Common.Update
{
public class CheckForUpdatesRequest : WebRequestMessage
{
- public String Email { get; set; }
-
- public String Password { get; set; }
+ public String Token { get; set; }
public String Version { get; set; }
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs
index b0577f40b..ae1e958ab 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs
@@ -18,8 +18,6 @@ namespace Tango.MachineStudio.Common.Update
public String Comments { get; set; }
- public bool ForcedUpdate { get; set; }
-
public String BlobAddress { get; set; }
}
}
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 450756705..4acc76c25 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs
@@ -63,6 +63,8 @@ namespace Tango.MachineStudio.UI.Authentication
}).Result;
+ AccessToken = response.Token;
+
ObservablesContext.OverrideSettingsDataSource(response.DataSource);
ObservablesStaticCollections.Instance.Initialize();
@@ -107,5 +109,10 @@ namespace Tango.MachineStudio.UI.Authentication
{
CurrentUser = null;
}
+
+ /// <summary>
+ /// Gets the access token that was retrieved at the last login.
+ /// </summary>
+ public string AccessToken { get; private set; }
}
}
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 6e8d0488b..283ea3637 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
@@ -91,48 +91,6 @@ namespace Tango.MachineStudio.UI.ViewModels
{
try
{
- Status = "Checking for critical updates...";
-
- LogManager.Log("Checking for forced update...");
-
- var client = new MachineStudioUpdateService();
-
- CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest()
- {
- Email = "ForceUpdate",
- Password = "ForceUpdate",
- Version = ApplicationManager.Version.ToString(),
- }).Result;
-
- if (response.IsUpdateAvailable && response.ForcedUpdate)
- {
- LogManager.Log("Forced update found, Navigating to update view!");
-
- InvokeUI(() =>
- {
- if (_notificationProvider.ShowQuestion("Machine Studio has detected a critical update which must be installed in order for the application to run properly. Do you wish to download and install this update?"))
- {
- TangoMessenger.Default.Send(new Messages.ForcedUpdateMessage() { UpdateResponse = response });
- _navigationManager.NavigateTo(NavigationView.UpdateView);
- }
- else
- {
- ApplicationManager.ShutDown();
- }
-
- IsLoading = false;
- });
-
- return;
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error checking for forced update!");
- }
-
- try
- {
Status = "Connecting to Team Foundation Services...";
_tfs.Initialize();
Thread.Sleep(500);
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index befad162c..818d507ae 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -363,8 +363,7 @@ namespace Tango.MachineStudio.UI.ViewModels
CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest()
{
- Email = _authenticationProvider.CurrentUser.Email,
- Password = _authenticationProvider.CurrentUser.Password,
+ Token = _authenticationProvider.AccessToken,
Version = _applicationManager.Version.ToString(),
AcceptBetaRelease = _settings.AcceptBetaRelease,
}).Result;
@@ -455,7 +454,7 @@ namespace Tango.MachineStudio.UI.ViewModels
//Check machine exist on my database first
if (x.SelectedMachine.Machine == null)
{
- _notificationProvider.ShowError( $"The specified machine '{x.SelectedMachine.SerialNumber}' could not be found on the database. Aborting connection.");
+ _notificationProvider.ShowError($"The specified machine '{x.SelectedMachine.SerialNumber}' could not be found on the database. Aborting connection.");
return;
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
index 3fec96629..e19dcdbe5 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
@@ -196,8 +196,7 @@ namespace Tango.MachineStudio.UI.ViewModels
CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest()
{
- Email = _authentication.CurrentUser.Email,
- Password = _authentication.CurrentUser.Password,
+ Token = _authentication.AccessToken,
Version = _application.Version.ToString(),
AcceptBetaRelease = settings.AcceptBetaRelease,
}).Result;
diff --git a/Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs b/Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs
new file mode 100644
index 000000000..20fc8ab50
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Web.Authentication
+{
+ public class TokensManager
+ {
+ private List<String> _tokens;
+
+ public TokensManager()
+ {
+ _tokens = new List<string>();
+ }
+
+ public String CreateNew()
+ {
+ String token = Guid.NewGuid().ToString();
+ _tokens.Add(token);
+ return token;
+ }
+
+ public bool Exists(String token)
+ {
+ return _tokens.Contains(token);
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs b/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs
index a581d9ec7..9d9016d5a 100644
--- a/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs
+++ b/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs
@@ -65,7 +65,7 @@ namespace Tango.Web.Controllers
code = HttpStatusCode.Unauthorized;
}
- throw new HttpResponseException(Request.CreateErrorResponse(code, ex.Message));
+ throw new HttpResponseException(Request.CreateErrorResponse(code, ex.ToString()));
}
}
}
diff --git a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj
index 9d199a409..385b3bde8 100644
--- a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj
+++ b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj
@@ -228,6 +228,7 @@
<Compile Include="..\Versioning\GlobalVersionInfo.cs">
<Link>GlobalVersionInfo.cs</Link>
</Compile>
+ <Compile Include="Authentication\TokensManager.cs" />
<Compile Include="Storage\ExtensionMethods.cs" />
<Compile Include="Storage\StorageManager.cs" />
<Compile Include="WebConfig.cs" />
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
index 8d46ed7d9..18f8dbc0b 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
@@ -18,15 +18,18 @@ using Tango.MachineStudio.Common.Update;
using Tango.Web.Controllers;
using Tango.Web.Helpers;
using Tango.Web.Storage;
+using Tango.Web.Authentication;
namespace Tango.MachineService.Controllers
{
public class MachineStudioController : JsonController
{
+ private static TokensManager _tokens_manager;
private static List<MachineStudioPendingUpload> _pendingUploads;
static MachineStudioController()
{
+ _tokens_manager = new TokensManager();
_pendingUploads = new List<MachineStudioPendingUpload>();
}
@@ -41,15 +44,7 @@ namespace Tango.MachineService.Controllers
using (ObservablesContext db = ObservablesContextHelper.CreateContext())
{
- //Load relation first...
- db.Roles.ToList();
- db.Permissions.ToList();
- db.UsersRoles.ToList();
- db.RolesPermissions.ToList();
-
- var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password);
-
- if (user != null && user.HasPermission(Permissions.RunMachineStudio) || (request.Email == "ForceUpdate"))
+ if (_tokens_manager.Exists(request.Token))
{
var versions = db.MachineStudioVersions.ToList();
@@ -66,8 +61,6 @@ namespace Tango.MachineService.Controllers
Version currentVersion = Version.Parse(request.Version);
- bool isForcedUpdate = versions.Exists(x => x.ForceUpdate && Version.Parse(x.Version) > currentVersion);
-
String comments = String.Join(Environment.NewLine, versions.OrderBy(x => Version.Parse(x.Version)).Where(x => Version.Parse(x.Version) > currentVersion).Select(x => x.Comments));
if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersion)
@@ -81,13 +74,12 @@ namespace Tango.MachineService.Controllers
response.IsUpdateAvailable = true;
response.Version = latestVersion.Version;
response.Comments = latestVersion.Comments;
- response.ForcedUpdate = isForcedUpdate;
response.IsStable = latestVersion.Stable;
}
}
else
{
- throw new AuthenticationException("Invalid user credentials.");
+ throw new AuthenticationException("Invalid token.");
}
}
@@ -245,7 +237,9 @@ namespace Tango.MachineService.Controllers
IntegratedSecurity = false,
UserName = request.Email,
Password = request.Password,
- }
+ },
+
+ Token = _tokens_manager.CreateNew()
};
}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config
index 77d9a1bb3..097943016 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config
@@ -19,7 +19,7 @@
<add key="DB_PASSWORD" value="Aa123456" />
<add key="DB_CATALOG" value="Tango" />
- <add key="STORAGE" value="DefaultEndpointsProtocol=https;AccountName=tangostorage;AccountKey=S4z/D+Yg6mwMis+bs/VpcDLA9yE1iZaYq23shQlRIi2KmM9E7JY8zdZjeAPOPdG3gONHoNDEpsgH6D4cqQ/bsA==;EndpointSuffix=core.windows.net" />
+ <add key="STORAGE_ACCOUNT" value="DefaultEndpointsProtocol=https;AccountName=tangostorage;AccountKey=S4z/D+Yg6mwMis+bs/VpcDLA9yE1iZaYq23shQlRIi2KmM9E7JY8zdZjeAPOPdG3gONHoNDEpsgH6D4cqQ/bsA==;EndpointSuffix=core.windows.net" />
<add key="TENANT_ID" value="2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4" />
<add key="CLIENT_ID" value="ec612854-7abc-457b-808a-5d0c5ba80c57" />