diff --git a/src/UniversalDashboard.UITest/Integration/Https.Tests.ps1 b/src/UniversalDashboard.UITest/Integration/Https.Tests.ps1 index cfd37dee..294d6ef8 100644 --- a/src/UniversalDashboard.UITest/Integration/Https.Tests.ps1 +++ b/src/UniversalDashboard.UITest/Integration/Https.Tests.ps1 @@ -35,6 +35,15 @@ Describe "Https" { Stop-UDDashboard -Server $Dashboard } + + It "should redirect HTTP" { + $Dashboard = Start-UDDashboard -Port 10001 -Certificate $Cert + + $Request = Invoke-WebRequest http://localhost:10001/dashboard + $Request.StatusCode | Should be 200 + + Stop-UDDashboard -Server $Dashboard + } } Get-UDDashboard | Stop-UDDashboard @@ -57,4 +66,4 @@ Describe "Https" { Remove-Item $CertPath -Force } } -} \ No newline at end of file +} diff --git a/src/UniversalDashboard/Server/ServerStartup.cs b/src/UniversalDashboard/Server/ServerStartup.cs index b2e5f379..09984112 100644 --- a/src/UniversalDashboard/Server/ServerStartup.cs +++ b/src/UniversalDashboard/Server/ServerStartup.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; @@ -111,7 +112,7 @@ public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHos await context.Next(context.HttpContext); } }); - + app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(env.ContentRootPath), @@ -120,6 +121,8 @@ public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHos ContentTypeProvider = provider }); + app.UseHttpsRedirection(); + var dashboardService = app.ApplicationServices.GetService(typeof(IDashboardService)) as IDashboardService; if (dashboardService?.DashboardOptions?.PublishedFolders != null) { @@ -147,4 +150,4 @@ public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHos app.UseMvc(); } } -} \ No newline at end of file +} diff --git a/src/UniversalDashboard/Themes/Azure.psd1 b/src/UniversalDashboard/Themes/Azure.psd1 index b7b16c80..ee41bfb4 100644 --- a/src/UniversalDashboard/Themes/Azure.psd1 +++ b/src/UniversalDashboard/Themes/Azure.psd1 @@ -1,231 +1,231 @@ -@{ -Name = "Azure" -Definition = @{ -UDDashboard = @{ -BackgroundColor = "#333333" -FontColor = "#FFFFF" -} -UDNavBar = @{ -BackgroundColor = "#1c1c1c" -FontColor = "#55b3ff" -} -UDCard= @{ -BackgroundColor = "#252525" -FontColor = "#FFFFFF" -'border-radius' = "12px" -} -UDChart= @{ -BackgroundColor = "#252525" -FontColor = "#FFFFFF" -'border-radius' = "12px" -} -UDMonitor= @{ -BackgroundColor = "#252525" -FontColor = "#FFFFFF" -'border-radius' = "12px" -} -UDTable= @{ -BackgroundColor = "#252525" -FontColor = "#FFFFFF" -'border-radius' = "12px" -} -UDGrid= @{ -BackgroundColor = "#252525" -FontColor = "#FFFFFF" -'border-radius' = "12px" -} -UDCounter= @{ -BackgroundColor = "#252525" -FontColor = "#FFFFFF" -'border-radius' = "12px" -} -UDInput= @{ -BackgroundColor = "#252525" -FontColor = "#FFFFFF" - -} -UDFooter = @{ -BackgroundColor = "#1c1c1c" -FontColor = "#55b3ff" -"margin-top" = "4% !important" -} -'.tabs'= @{ -'color'= "#55b3ff" -'margin-top' = "64px" -'background-color' = "#333333" -'z-index' = "9998" -} -'.tabs .tab'= @{ -'color' = "#252525" -} - -'.tabs .tab a:hover' = @{ -'background-color' = "#252525" -'color'= "#55b3ff" -} - -'.tabs .tab a.active'= @{ -'background-color' = "#1c1c1c" -'color'= "#55b3ff" -} -'.tabs .tab a:focus.active'= @{ - -'background-color' = "#252525" -'color'= "#55b3ff" -} -'.tabs .indicator'= @{ -'background-color' = "#55b3ff" -} -'.tabs .tab a' = @{ -'color' = "#FFFFFF" -} - -'[type="radio"]:checked + span::after' = @{ - -'background-color' = "#55b3ff" - -} -'.pagination li a'= @{ -'color' = "#fff !important" -} -".ud-navbar"= @{ -'width' = "100%" -'position' = "fixed" -'z-index'= "9999" -} -'nav' = @{ -'left'= "0" -'right' = "0" - -} -'input:not([type]), input[type="date"]:not(.browser-default), input[type="datetime-local"]:not(.browser-default), input[type="datetime"]:not(.browser-default), input[type="email"]:not(.browser-default), input[type="number"]:not(.browser-default), input[type="password"]:not(.browser-default), input[type="search"]:not(.browser-default), input[type="tel"]:not(.browser-default), input[type="text"]:not(.browser-default), input[type="time"]:not(.browser-default), input[type="url"]:not(.browser-default), textarea.materialize-textarea' = @{ -'border-bottom' = "1px solid #55b3ff" -'color'= "#FFFFFF" -} -'.select-wrapper input.select-dropdown'= @{ -'color'= "#ffffff" -'border-bottom' = "1px solid #55b3ff" -'border-block-end-color' = "#55b3ff" -} -'.dropdown-content'= @{ -'background-color' = "#333333" -} -'.btn'= @{ -'color'= "#1c1c1c" -'background-color' = "#bababa" -'border-radius' = "8px" -} -'.btn:hover'= @{ -'color'= "#ffffff" -'background-color' = "#55b3ff" -} -'.btn-floating'= @{ -'color'= "#1c1c1c" -'background-color' = "#bababa" -} -'.select-dropdown li span' = @{ -'color' = "#ffffff" -} - -'.sidenav'= @{ -'background-color' = "#1c1c1c" -'margin-top' = "75px" -'height'= "77%" -'border-radius' = "8px" -'box-shadow' = "none" -'z-index' = "0" -'color'= "#fff" -} - -'.sidenav a:hover'= @{ -'background-color' = "#1e353f" -'color'= "#55b3ff" -} -'.sidenav li > a' = @{ -'color'= "#f1f1f1" -'font-size' = "18px" -} -'li'= @{ -'color' = "#55b3ff" -} -'.collapsible-header'= @{ -'background-color' = "#252525" -'border-bottom' = "1px solid #55b3ff" -} -'.collapsible' = @{ -"border-top"= "1px solid #55b3ff" -"border-right" = "1px solid #55b3ff" -"border-left"= "1px solid #55b3ff" -'margin' = ".5rem 0 1rem" -} -'h'= @{ -"color" = "#fff !important" -} -'h3, h4' = @{ -'line-height' = "110%" -'color' = "#fff" -} -'.collapsible-body'= @{ -"background-color" = "#252525" -"border-bottom" = "1px solid #55b3ff" -} -'[type="checkbox"]:checked + span:not(.lever)::before'= @{ -"border-right"= "2px solid #55b3ff" -"border-bottom" = "2px solid #55b3ff" -} -'.collection .collection-item'= @{ -'background-color' = "#252525" -} -'img' = @{ -'border-radius' = "8px" -'float'= "left" -} -'.pagination li.active' = @{ -'background-color' = "#55b3ff" -} -'.divider'= @{ -'height'= "1px" -'overflow'= "hidden" -'background-color' = "#55b3ff" -} -'.sidenav .collapsible-header'= @{ -'color'= "#fff !important" -'background-color' = "#1c1c1c !important" -'font-size'= "18px" -} -'ul:not(.browser-default)' = @{ -'padding-left'= "0" -'list-style-type'= "none" -'background-color' = "#1c1c1c" -} -'.card .card-action a:not(.btn):not(.btn-large):not(.btn-small):not(.btn-large):not(.btn-floating)'= @{ -'color'= "#55b3ff" -'margin-right' = "24px" -'-webkit-transition' = "color .3s ease" -'transition'= "color .3s ease" -'text-transform'= "uppercase" -} -'.btn-flat' = @{ -'color' = "#fff" -} -'.sidenav .subheader' = @{ -'color' = "#fff" -'font-size' = "18px" -} -'.svg-inline--fa' = @{ -'color' = "#fff" -} -'.modal'= @{ -'z-index' = "9999 !important" -'max-width' = "90% !important" -'max-height' = "90% !important" -'width' = "90% !important" -'color' = "#000" -'background-color' = "#a3a3a3" -} -'header, nav, section' = @{ -'display' = "block" -'margin-bottom' = "5%" -} -} +@{ +Name = "Azure" +Definition = @{ +UDDashboard = @{ +BackgroundColor = "#333333" +FontColor = "#FFFFF" +} +UDNavBar = @{ +BackgroundColor = "#1c1c1c" +FontColor = "#55b3ff" +} +UDCard= @{ +BackgroundColor = "#252525" +FontColor = "#FFFFFF" +'border-radius' = "12px" +} +UDChart= @{ +BackgroundColor = "#252525" +FontColor = "#FFFFFF" +'border-radius' = "12px" +} +UDMonitor= @{ +BackgroundColor = "#252525" +FontColor = "#FFFFFF" +'border-radius' = "12px" +} +UDTable= @{ +BackgroundColor = "#252525" +FontColor = "#FFFFFF" +'border-radius' = "12px" +} +UDGrid= @{ +BackgroundColor = "#252525" +FontColor = "#FFFFFF" +'border-radius' = "12px" +} +UDCounter= @{ +BackgroundColor = "#252525" +FontColor = "#FFFFFF" +'border-radius' = "12px" +} +UDInput= @{ +BackgroundColor = "#252525" +FontColor = "#FFFFFF" + +} +UDFooter = @{ +BackgroundColor = "#1c1c1c" +FontColor = "#55b3ff" +"margin-top" = "4% !important" +} +'.tabs'= @{ +'color'= "#55b3ff" +'margin-top' = "64px" +'background-color' = "#333333" +'z-index' = "9998" +} +'.tabs .tab'= @{ +'color' = "#252525" +} + +'.tabs .tab a:hover' = @{ +'background-color' = "#252525" +'color'= "#55b3ff" +} + +'.tabs .tab a.active'= @{ +'background-color' = "#1c1c1c" +'color'= "#55b3ff" +} +'.tabs .tab a:focus.active'= @{ + +'background-color' = "#252525" +'color'= "#55b3ff" +} +'.tabs .indicator'= @{ +'background-color' = "#55b3ff" +} +'.tabs .tab a' = @{ +'color' = "#FFFFFF" +} + +'[type="radio"]:checked + span::after' = @{ + +'background-color' = "#55b3ff" + +} +'.pagination li a'= @{ +'color' = "#fff !important" +} +".ud-navbar"= @{ +'width' = "100%" +'position' = "fixed" +'z-index'= "9999" +} +'nav' = @{ +'left'= "0" +'right' = "0" + +} +'input:not([type]), input[type="date"]:not(.browser-default), input[type="datetime-local"]:not(.browser-default), input[type="datetime"]:not(.browser-default), input[type="email"]:not(.browser-default), input[type="number"]:not(.browser-default), input[type="password"]:not(.browser-default), input[type="search"]:not(.browser-default), input[type="tel"]:not(.browser-default), input[type="text"]:not(.browser-default), input[type="time"]:not(.browser-default), input[type="url"]:not(.browser-default), textarea.materialize-textarea' = @{ +'border-bottom' = "1px solid #55b3ff" +'color'= "#FFFFFF" +} +'.select-wrapper input.select-dropdown'= @{ +'color'= "#ffffff" +'border-bottom' = "1px solid #55b3ff" +'border-block-end-color' = "#55b3ff" +} +'.dropdown-content'= @{ +'background-color' = "#333333" +} +'.btn'= @{ +'color'= "#1c1c1c" +'background-color' = "#bababa" +'border-radius' = "8px" +} +'.btn:hover'= @{ +'color'= "#ffffff" +'background-color' = "#55b3ff" +} +'.btn-floating'= @{ +'color'= "#1c1c1c" +'background-color' = "#bababa" +} +'.select-dropdown li span' = @{ +'color' = "#ffffff" +} + +'.sidenav'= @{ +'background-color' = "#1c1c1c" +'margin-top' = "75px" +'height'= "77%" +'border-radius' = "8px" +'box-shadow' = "none" +'z-index' = "0" +'color'= "#fff" +} + +'.sidenav a:hover'= @{ +'background-color' = "#1e353f" +'color'= "#55b3ff" +} +'.sidenav li > a' = @{ +'color'= "#f1f1f1" +'font-size' = "18px" +} +'li'= @{ +'color' = "#55b3ff" +} +'.collapsible-header'= @{ +'background-color' = "#252525" +'border-bottom' = "1px solid #55b3ff" +} +'.collapsible' = @{ +"border-top"= "1px solid #55b3ff" +"border-right" = "1px solid #55b3ff" +"border-left"= "1px solid #55b3ff" +'margin' = ".5rem 0 1rem" +} +'h'= @{ +"color" = "#fff !important" +} +'h3, h4' = @{ +'line-height' = "110%" +'color' = "#fff" +} +'.collapsible-body'= @{ +"background-color" = "#252525" +"border-bottom" = "1px solid #55b3ff" +} +'[type="checkbox"]:checked + span:not(.lever)::before'= @{ +"border-right"= "2px solid #55b3ff" +"border-bottom" = "2px solid #55b3ff" +} +'.collection .collection-item'= @{ +'background-color' = "#252525" +} +'img' = @{ +'border-radius' = "8px" +'float'= "left" +} +'.pagination li.active' = @{ +'background-color' = "#55b3ff" +} +'.divider'= @{ +'height'= "1px" +'overflow'= "hidden" +'background-color' = "#55b3ff" +} +'.sidenav .collapsible-header'= @{ +'color'= "#fff !important" +'background-color' = "#1c1c1c !important" +'font-size'= "18px" +} +'ul:not(.browser-default)' = @{ +'padding-left'= "0" +'list-style-type'= "none" +'background-color' = "#1c1c1c" +} +'.card .card-action a:not(.btn):not(.btn-large):not(.btn-small):not(.btn-large):not(.btn-floating)'= @{ +'color'= "#55b3ff" +'margin-right' = "24px" +'-webkit-transition' = "color .3s ease" +'transition'= "color .3s ease" +'text-transform'= "uppercase" +} +'.btn-flat' = @{ +'color' = "#fff" +} +'.sidenav .subheader' = @{ +'color' = "#fff" +'font-size' = "18px" +} +'.svg-inline--fa' = @{ +'color' = "#fff" +} +'.modal'= @{ +'z-index' = "9999 !important" +'max-width' = "90% !important" +'max-height' = "90% !important" +'width' = "90% !important" +'color' = "#000" +'background-color' = "#a3a3a3" +} +'header, nav, section' = @{ +'display' = "block" +'margin-bottom' = "5%" +} +} } \ No newline at end of file diff --git a/src/UniversalDashboard/UniversalDashboard.csproj b/src/UniversalDashboard/UniversalDashboard.csproj index 138dab02..5f4b51c6 100644 --- a/src/UniversalDashboard/UniversalDashboard.csproj +++ b/src/UniversalDashboard/UniversalDashboard.csproj @@ -7,16 +7,16 @@ bb012ad5-1680-4d35-b8ce-9439c394fefa - + AnyCPU - + - + PreserveNewest @@ -25,7 +25,7 @@ PreserveNewest - + @@ -38,6 +38,7 @@ + @@ -57,16 +58,16 @@ - + PreserveNewest PreserveNewest - + PreserveNewest PreserveNewest - + PreserveNewest PreserveNewest diff --git a/test.ps1 b/test.ps1 new file mode 100644 index 00000000..998b56a2 --- /dev/null +++ b/test.ps1 @@ -0,0 +1,7 @@ +$Cert = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -DnsName localhost + +Start-UDDashboard -Content { + New-UDDashboard -Title "Secure Dashboard" -Content { + New-UDElement -Tag "h1" -Content { "hi" } + } +} -Port 12000 -Certificate $Cert