diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-27 15:14:10 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-27 15:14:10 +0200 |
| commit | 9e42e1c87f3a206f0babc74760ac9a02d8d328f4 (patch) | |
| tree | be3be4cf23f524f430146af472883f63dd8bdfb7 /Software/Visual_Studio/Web/Tango.MachineService | |
| parent | 894d05d59c0e1612903f1adbf908914f2df67ccc (diff) | |
| download | Tango-9e42e1c87f3a206f0babc74760ac9a02d8d328f4.tar.gz Tango-9e42e1c87f3a206f0babc74760ac9a02d8d328f4.zip | |
Implemented Deployment Slots!
Implemented Environment AD Groups.
Implemented Machine Studio environment selection.
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService')
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs | 32 | ||||
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Development.pubxml | 28 | ||||
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Production.pubxml (renamed from Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml) | 4 | ||||
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Testing.pubxml | 28 | ||||
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj | 4 | ||||
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Web.config | 15 |
6 files changed, 105 insertions, 6 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs index d21a23ca1..4aff8fd39 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -19,6 +19,7 @@ using Tango.Web.Controllers; using Tango.Web.Helpers; using Tango.Web.Storage; using Tango.Web.Authentication; +using Tango.Web.ActiveDirectory; namespace Tango.MachineService.Controllers { @@ -26,6 +27,7 @@ namespace Tango.MachineService.Controllers { private static TokensManager _tokens_manager; private static List<MachineStudioPendingUpload> _pendingUploads; + private ActiveDirectoryManager _ad_manager; static MachineStudioController() { @@ -33,6 +35,11 @@ namespace Tango.MachineService.Controllers _pendingUploads = new List<MachineStudioPendingUpload>(); } + public MachineStudioController() : base() + { + _ad_manager = new ActiveDirectoryManager(); + } + #region Update [HttpPost] @@ -189,7 +196,12 @@ namespace Tango.MachineService.Controllers [HttpPost] public LoginResponse Login(LoginRequest request) { - AuthenticationResult authResult = AzureDirectoryHelper.AuthenticateUser(request.Email, request.Password); + var authResult =_ad_manager.ValidateUserCredentials(request.Email, request.Password); + + if (!_ad_manager.CanUserAccessCurrentEnvironment(request.Email)) + { + throw new AuthenticationException($"You do not have permissions to access the {MachineServiceConfig.DEPLOYMENT_SLOT.ToDescription()} environment."); + } using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { @@ -217,11 +229,25 @@ namespace Tango.MachineService.Controllers FullName = authResult.UserInfo.GivenName + " " + authResult.UserInfo.FamilyName, Email = request.Email, }; - new_user.Roles.Add(db.Roles.Single(x => (Roles)x.Code == Roles.User)); - new_user.Roles.Add(db.Roles.Single(x => (Roles)x.Code == Roles.MachineStudioUser)); + + db.UsersRoles.Add(new UsersRole() + { + User = new_user, + Role = db.Roles.Single(x => (Roles)x.Code == Roles.User), + }); + + db.UsersRoles.Add(new UsersRole() + { + User = new_user, + Role = db.Roles.Single(x => (Roles)x.Code == Roles.MachineStudioUser), + }); + + new_user.LastLogin = DateTime.UtcNow; + db.Users.Add(new_user); } else { + user.LastLogin = DateTime.UtcNow; user.Password = g.Encrypt(request.Password); } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Development.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Development.pubxml new file mode 100644 index 000000000..e847adbd8 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Development.pubxml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +This file is used by the publish/package process of your Web project. You can customize the behavior of this process +by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. +--> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <WebPublishMethod>MSDeploy</WebPublishMethod> + <ResourceId>/subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/machineservice/slots/MachineService-DEV</ResourceId> + <ResourceGroup>Tango</ResourceGroup> + <PublishProvider>AzureWebSite</PublishProvider> + <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration> + <LastUsedPlatform>Any CPU</LastUsedPlatform> + <SiteUrlToLaunchAfterPublish>http://machineservice-machineservice-dev.azurewebsites.net</SiteUrlToLaunchAfterPublish> + <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> + <ExcludeApp_Data>False</ExcludeApp_Data> + <MSDeployServiceURL>machineservice-machineservice-dev.scm.azurewebsites.net:443</MSDeployServiceURL> + <DeployIisAppPath>machineservice__MachineService-DEV</DeployIisAppPath> + <RemoteSitePhysicalPath /> + <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer> + <InstallAspNetCoreSiteExtension>False</InstallAspNetCoreSiteExtension> + <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod> + <EnableMSDeployBackup>True</EnableMSDeployBackup> + <UserName>$machineservice__MachineService-DEV</UserName> + <_SavePWD>True</_SavePWD> + <_DestinationType>AzureWebSite</_DestinationType> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Production.pubxml index 612e38bfb..a611d5ffd 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Production.pubxml @@ -9,9 +9,9 @@ by editing this MSBuild file. In order to learn more about this please visit htt <ResourceId>/subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/MachineService</ResourceId> <ResourceGroup>Tango</ResourceGroup> <PublishProvider>AzureWebSite</PublishProvider> - <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration> + <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedPlatform>Any CPU</LastUsedPlatform> - <SiteUrlToLaunchAfterPublish>http://machineservice.azurewebsites.net</SiteUrlToLaunchAfterPublish> + <SiteUrlToLaunchAfterPublish>https://machineservice.twine-srv.com</SiteUrlToLaunchAfterPublish> <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> <ExcludeApp_Data>False</ExcludeApp_Data> <MSDeployServiceURL>machineservice.scm.azurewebsites.net:443</MSDeployServiceURL> diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Testing.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Testing.pubxml new file mode 100644 index 000000000..12e2de377 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Testing.pubxml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +This file is used by the publish/package process of your Web project. You can customize the behavior of this process +by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. +--> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <WebPublishMethod>MSDeploy</WebPublishMethod> + <ResourceId>/subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/machineservice/slots/MachineService-TEST</ResourceId> + <ResourceGroup>Tango</ResourceGroup> + <PublishProvider>AzureWebSite</PublishProvider> + <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> + <LastUsedPlatform>Any CPU</LastUsedPlatform> + <SiteUrlToLaunchAfterPublish>http://machineservice-machineservice-test.azurewebsites.net</SiteUrlToLaunchAfterPublish> + <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> + <ExcludeApp_Data>False</ExcludeApp_Data> + <MSDeployServiceURL>machineservice-machineservice-test.scm.azurewebsites.net:443</MSDeployServiceURL> + <DeployIisAppPath>machineservice__MachineService-TEST</DeployIisAppPath> + <RemoteSitePhysicalPath /> + <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer> + <InstallAspNetCoreSiteExtension>False</InstallAspNetCoreSiteExtension> + <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod> + <EnableMSDeployBackup>True</EnableMSDeployBackup> + <UserName>$machineservice__MachineService-TEST</UserName> + <_SavePWD>True</_SavePWD> + <_DestinationType>AzureWebSite</_DestinationType> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index ca1376ff7..63c8521da 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -346,7 +346,9 @@ <Folder Include="App_Data\" /> </ItemGroup> <ItemGroup> - <None Include="Properties\PublishProfiles\MachineService - Web Deploy.pubxml" /> + <None Include="Properties\PublishProfiles\Development.pubxml" /> + <None Include="Properties\PublishProfiles\Testing.pubxml" /> + <None Include="Properties\PublishProfiles\Production.pubxml" /> <None Include="Properties\PublishProfiles\Publish Machine Service via FTP.pubxml" /> </ItemGroup> <PropertyGroup> diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index 097943016..2d700244b 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -27,6 +27,9 @@ <add key="TANGO_VERSIONS_CONTAINER" value="tango-versions" /> <add key="MACHINE_STUDIO_VERSIONS_CONTAINER" value="machine-studio-versions" /> + + <add key="DEPLOYMENT_SLOT" value="DEV" /> + <add key="ENVIRONMENT_GROUP" value="Tango DEV" /> </appSettings> <!-- For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367. @@ -134,6 +137,18 @@ <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <system.codedom> |
