From e223fdf095197ad5a3ff40f4b897edf7dffb39fd Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 24 Jan 2021 14:58:01 +0100 Subject: [PATCH] Build fix. --- backend/i18n/source/backend_en.json | 18 ++- backend/src/Squidex.Shared/Texts.it.resx | 48 ++++-- backend/src/Squidex.Shared/Texts.nl.resx | 48 ++++-- backend/src/Squidex.Shared/Texts.resx | 48 ++++-- .../Controllers/Account/AccountController.cs | 1 - .../Controllers/Account/LoginVM.cs | 3 +- .../Controllers/Setup/SetupController.cs | 17 ++- .../Controllers/Setup/SetupVM.cs | 8 +- .../IdentityServer/Views/Account/Login.cshtml | 48 +++--- .../IdentityServer/Views/Setup/Setup.cshtml | 140 +++++++++++------- .../RequestExceptionMiddlewareTests.cs | 35 +++-- frontend/app/theme/_common.scss | 4 + 12 files changed, 281 insertions(+), 137 deletions(-) diff --git a/backend/i18n/source/backend_en.json b/backend/i18n/source/backend_en.json index 7af66a2d6..ac1ece3ff 100644 --- a/backend/i18n/source/backend_en.json +++ b/backend/i18n/source/backend_en.json @@ -45,6 +45,7 @@ "common.clientSecret": "Client Secret", "common.contentType": "Content type", "common.contributorId": "Contributor ID or email", + "common.critical": "Critial", "common.data": "Data", "common.defaultValue": "Default value", "common.displayName": "Display name", @@ -112,8 +113,10 @@ "common.save": "Save", "common.schemaId": "Schema ID", "common.signup": "Signup", + "common.success": "Success", "common.text": "Text", "common.trigger": "Trigger", + "common.warning": "Warning", "common.workflow": "Workflow", "common.workflowStep": "Step", "common.workflowTransition": "Transition", @@ -277,15 +280,20 @@ "setup.createUser.loginHint": "You have configured at least one external authentication provider such as Google. Just go to the login page and login to become administrator.", "setup.createUser.loginLink": "Go to Login Page.", "setup.createUser.separator": "OR", - "setup.headline": "One Time Installation", + "setup.headline": "Installation", "setup.hint": "You are seeing this screen because no user exists yet. After a user is created, you are not able to use this screen again.", - "setup.https.failure": " You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the X-Forwarded-* headers.", - "setup.https.success": "Congratulations, you are accessing your Squidex installation over a secure connection (https).", "setup.madeBy": "Proudly made by", "setup.madeByCopyright": "Sebastian Stehle and Contributors, 2016-2021", + "setup.ruleAppCreation.warningAdmins": "With your setup, only admins can create new apps. If you want to change this set UI__ONLYADMINSCANCREATEAPPS=false as environment variable.", + "setup.ruleAppCreation.warningAll": "With your setup, every user can create new apps. If you want to change this set UI__ONLYADMINSCANCREATEAPPS=true as environment variable.", + "setup.ruleFolder.warning": "You are using the folder asset store where all assets are stored in the file system. Please remember to include the asset folder into your backup strategy and map it to a volume, if you are using Docker.", + "setup.ruleFtp.warning": "You are using the FTP asset store. It is not recommended to use this storage type because of bad performance.", + "setup.ruleHttps.failure": " You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the X-Forwarded-* headers.", + "setup.ruleHttps.success": "Congratulations, you are accessing your Squidex installation over a secure connection (https).", + "setup.rules.headline": "System Checklist", + "setup.ruleUrl.failure": "You should access Squidex only over one one canonical URL and configure this URL over the URLS__BASEURL environment variable. The current base URL {actual} does not match to the base url {configured}.", + "setup.ruleUrl.success": "Congratulations the URLS__BASEURL environment variable is configured properly.", "setup.title": "Installation", - "setup.url.failure": "You should access Squidex only over one one canonical URL and configure this URL over the URLS__BASEURL environment variable. The current base URL {actual} does not match to the base url {configured}.", - "setup.url.success": "Congratulations the URLS__BASEURL environment variable is configured properly.", "users.accessDenied.text": "This operation is not allowed, your account might be locked.", "users.accessDenied.title": "Access denied", "users.consent.agree": "I agree!", diff --git a/backend/src/Squidex.Shared/Texts.it.resx b/backend/src/Squidex.Shared/Texts.it.resx index 514e66d05..056aa9eb2 100644 --- a/backend/src/Squidex.Shared/Texts.it.resx +++ b/backend/src/Squidex.Shared/Texts.it.resx @@ -220,6 +220,9 @@ ID o Email del collaboratore + + Critial + Data @@ -421,12 +424,18 @@ Iscriviti + + Success + Testo Trigger + + Warning + Workflow @@ -917,16 +926,10 @@ OR - One Time Installation + Installation - You are seeing this screen because no user exists yet. After a user is created you are not able to use this screen again. - - - You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the <code>X-Forwarded-*</code> headers. - - - Congratulations, you are accessing your Squidex installation over a secure connection (https). + You are seeing this screen because no user exists yet. After a user is created, you are not able to use this screen again. Proudly made by @@ -934,15 +937,36 @@ Sebastian Stehle and Contributors, 2016-2021 - - Installation + + With your setup, only admins can create new apps. If you want to change this set <code>UI__ONLYADMINCANCREATEAPPS=false</code> as environment variable. + + + With your setup, every user can create new apps. If you want to change this set <code>UI__ONLYADMINCANCREATEAPPS=true</code> as environment variable. - + + You are using the <strong>folder asset store</strong> where all assets are stored in the file system. Please remember to include the asset folder into your backup strategy and map it to a volume, if you are using Docker. + + + You are using the <strong>FTP asset store</strong>. It is not recommended to use this storage type because of bad performance. + + + You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the <code>X-Forwarded-*</code> headers. + + + Congratulations, you are accessing your Squidex installation over a secure connection (https). + + + System Checklist + + You should access Squidex only over one one canonical URL and configure this URL over the <code>URLS__BASEURL</code> environment variable. The current base URL <code>{actual}</code> does not match to the base url <code>{configured}</code>. - + Congratulations the <code>URLS__BASEURL</code> environment variable is configured properly. + + Installation + Questa operazione non รจ consentita, il tuo account potrebbe essere bloccato. diff --git a/backend/src/Squidex.Shared/Texts.nl.resx b/backend/src/Squidex.Shared/Texts.nl.resx index d5d629380..d3fc592a5 100644 --- a/backend/src/Squidex.Shared/Texts.nl.resx +++ b/backend/src/Squidex.Shared/Texts.nl.resx @@ -220,6 +220,9 @@ Bijdrager-ID of e-mailadres + + Critial + Gegevens @@ -421,12 +424,18 @@ Aanmelden + + Success + Tekst Trigger + + Warning + Workflow @@ -917,16 +926,10 @@ OR - One Time Installation + Installation - You are seeing this screen because no user exists yet. After a user is created you are not able to use this screen again. - - - You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the <code>X-Forwarded-*</code> headers. - - - Congratulations, you are accessing your Squidex installation over a secure connection (https). + You are seeing this screen because no user exists yet. After a user is created, you are not able to use this screen again. Proudly made by @@ -934,15 +937,36 @@ Sebastian Stehle and Contributors, 2016-2021 - - Installation + + With your setup, only admins can create new apps. If you want to change this set <code>UI__ONLYADMINCANCREATEAPPS=false</code> as environment variable. + + + With your setup, every user can create new apps. If you want to change this set <code>UI__ONLYADMINCANCREATEAPPS=true</code> as environment variable. - + + You are using the <strong>folder asset store</strong> where all assets are stored in the file system. Please remember to include the asset folder into your backup strategy and map it to a volume, if you are using Docker. + + + You are using the <strong>FTP asset store</strong>. It is not recommended to use this storage type because of bad performance. + + + You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the <code>X-Forwarded-*</code> headers. + + + Congratulations, you are accessing your Squidex installation over a secure connection (https). + + + System Checklist + + You should access Squidex only over one one canonical URL and configure this URL over the <code>URLS__BASEURL</code> environment variable. The current base URL <code>{actual}</code> does not match to the base url <code>{configured}</code>. - + Congratulations the <code>URLS__BASEURL</code> environment variable is configured properly. + + Installation + Deze bewerking is niet toegestaan, je account is mogelijk vergrendeld. diff --git a/backend/src/Squidex.Shared/Texts.resx b/backend/src/Squidex.Shared/Texts.resx index 1d19f4c1d..77332a5be 100644 --- a/backend/src/Squidex.Shared/Texts.resx +++ b/backend/src/Squidex.Shared/Texts.resx @@ -220,6 +220,9 @@ Contributor ID or email + + Critial + Data @@ -421,12 +424,18 @@ Signup + + Success + Text Trigger + + Warning + Workflow @@ -917,16 +926,10 @@ OR - One Time Installation + Installation - You are seeing this screen because no user exists yet. After a user is created you are not able to use this screen again. - - - You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the <code>X-Forwarded-*</code> headers. - - - Congratulations, you are accessing your Squidex installation over a secure connection (https). + You are seeing this screen because no user exists yet. After a user is created, you are not able to use this screen again. Proudly made by @@ -934,15 +937,36 @@ Sebastian Stehle and Contributors, 2016-2021 - - Installation + + With your setup, only admins can create new apps. If you want to change this set <code>UI__ONLYADMINCANCREATEAPPS=false</code> as environment variable. + + + With your setup, every user can create new apps. If you want to change this set <code>UI__ONLYADMINCANCREATEAPPS=true</code> as environment variable. - + + You are using the <strong>folder asset store</strong> where all assets are stored in the file system. Please remember to include the asset folder into your backup strategy and map it to a volume, if you are using Docker. + + + You are using the <strong>FTP asset store</strong>. It is not recommended to use this storage type because of bad performance. + + + You are not accessing the site over https. If this warning is not correct then Squidex cannot detect https mode, because your instance is behind a reverse proxy such as nginx. Ensure that http headers are forwarded properly, via the <code>X-Forwarded-*</code> headers. + + + Congratulations, you are accessing your Squidex installation over a secure connection (https). + + + System Checklist + + You should access Squidex only over one one canonical URL and configure this URL over the <code>URLS__BASEURL</code> environment variable. The current base URL <code>{actual}</code> does not match to the base url <code>{configured}</code>. - + Congratulations the <code>URLS__BASEURL</code> environment variable is configured properly. + + Installation + This operation is not allowed, your account might be locked. diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs index da5ff8560..6d5f1e3f1 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs @@ -230,7 +230,6 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account IsFailed = isFailed, IsLogin = isLogin, HasPasswordAuth = allowPasswordAuth, - HasPasswordAndExternal = allowPasswordAuth && externalProviders.Any(), ReturnUrl = returnUrl }; diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/LoginVM.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/LoginVM.cs index 35d8cc8f5..85e331724 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/LoginVM.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/LoginVM.cs @@ -6,6 +6,7 @@ // ========================================================================== using System.Collections.Generic; +using System.Linq; namespace Squidex.Areas.IdentityServer.Controllers.Account { @@ -19,7 +20,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account public bool HasPasswordAuth { get; set; } - public bool HasPasswordAndExternal { get; set; } + public bool HasExternalLogin => ExternalProviders.Any(); public IReadOnlyList ExternalProviders { get; set; } } diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs index 83d5b9e62..4e44de4e2 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs @@ -12,6 +12,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; +using Squidex.Areas.Api.Controllers.UI; +using Squidex.Assets; using Squidex.Config; using Squidex.Domain.Users; using Squidex.Hosting; @@ -22,20 +24,26 @@ using Squidex.Infrastructure.Validation; namespace Squidex.Areas.IdentityServer.Controllers.Setup { - [AllowAnonymous] public class SetupController : IdentityServerController { + private readonly IAssetStore assetStore; private readonly IUrlGenerator urlGenerator; private readonly IUserService userService; + private readonly MyUIOptions uiOptions; private readonly MyIdentityOptions identityOptions; - public SetupController(IOptions identityOptions, + public SetupController( + IAssetStore assetStore, + IOptions uiOptions, + IOptions identityOptions, IUrlGenerator urlGenerator, IUserService userService) { + this.assetStore = assetStore; + this.identityOptions = identityOptions.Value; + this.uiOptions = uiOptions.Value; this.urlGenerator = urlGenerator; this.userService = userService; - this.identityOptions = identityOptions.Value; } [HttpGet] @@ -99,7 +107,10 @@ namespace Squidex.Areas.IdentityServer.Controllers.Setup BaseUrlConfigured = urlGenerator.BuildUrl(), BaseUrlCurrent = $"{request.Scheme}://{request.Host}", ErrorMessage = errorMessage, + EverybodyCanCreateApps = !uiOptions.OnlyAdminsCanCreateApps, IsValidHttps = HttpContext.Request.IsHttps, + IsAssetStoreFile = assetStore is FolderAssetStore, + IsAssetStoreFtp = assetStore is FTPAssetStore, HasExternalLogin = externalProviders.Any(), HasPasswordAuth = identityOptions.AllowPasswordAuth, }; diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupVM.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupVM.cs index a7f4ad869..228db32cb 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupVM.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupVM.cs @@ -19,10 +19,14 @@ namespace Squidex.Areas.IdentityServer.Controllers.Setup public bool IsValidHttps { get; set; } + public bool IsAssetStoreFtp { get; set; } + + public bool IsAssetStoreFile { get; set; } + + public bool EverybodyCanCreateApps { get; set; } + public bool HasExternalLogin { get; set; } public bool HasPasswordAuth { get; set; } - - public bool HasPasswordAndExternal { get; set; } } } diff --git a/backend/src/Squidex/Areas/IdentityServer/Views/Account/Login.cshtml b/backend/src/Squidex/Areas/IdentityServer/Views/Account/Login.cshtml index 806e752cf..669a6fa1e 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Views/Account/Login.cshtml +++ b/backend/src/Squidex/Areas/IdentityServer/Views/Account/Login.cshtml @@ -8,7 +8,7 @@ ViewBag.Title = action; } - +
@@ -45,7 +45,7 @@ } -@if (Model.HasPasswordAndExternal) +@if (Model.HasExternalLogin && Model.HasPasswordAuth) {
@T.Get("users.login.separator")
@@ -54,36 +54,36 @@ @if (Model.HasPasswordAuth) { - if (Model.IsLogin) + if (Model.IsLogin) + { + if (Model.IsFailed) { - if (Model.IsFailed) - { -
@T.Get("users.login.error")
- } +
@T.Get("users.login.error")
+ } -
-
- -
+ +
+ +
-
- -
+
+ +
- -
- } - else - { - - } + + + } + else + { + + } } @if (Model.IsLogin) {
} } + + void RenderRuleAsSuccess(string message) + { +
+
+
+ +
+
+ +
+
+ @Html.Raw(message) +
+
+
+ } + + void RenderRuleAsCritical(string message) + { +
+
+
+ +
+
+ +
+
+ @T.Get("common.critical"): @Html.Raw(message) +
+
+
+ } + + void RenderRuleAsWarning(string message) + { +
+
+
+ +
+
+ +
+
+ @T.Get("common.warning"): @Html.Raw(message) +
+
+
+ } }
@@ -26,63 +77,44 @@ @T.Get("setup.hint")
-

System Status

- -
- @if (Model.IsValidHttps) - { -
-
- -
-
+

@T.Get("setup.rules.headline")

-
- @Html.Raw(T.Get("setup.https.success")) -
- } - else - { -
-
- -
- -
- -
- @Html.Raw(T.Get("setup.https.failure")) -
- } -
+ @if (Model.IsValidHttps) + { + RenderRuleAsSuccess(T.Get("setup.ruleHttps.success")); + } + else + { + RenderRuleAsCritical(T.Get("setup.ruleHttps.failure")); + } -
- @if (Model.BaseUrlConfigured == Model.BaseUrlCurrent) - { -
-
- -
-
+ @if (Model.BaseUrlConfigured == Model.BaseUrlCurrent) + { + RenderRuleAsSuccess(T.Get("setup.ruleUrl.success")); + } + else + { + RenderRuleAsCritical(T.Get("setup.ruleUrl.failure", new { actual = Model.BaseUrlCurrent, configured = Model.BaseUrlConfigured })); + } -
- @Html.Raw(T.Get("setup.url.success")) -
- } - else - { -
-
- -
+ @if (Model.EverybodyCanCreateApps) + { + RenderRuleAsWarning(T.Get("setup.ruleAppCreation.warningAdmins")); + } + else + { + RenderRuleAsWarning(T.Get("setup.ruleAppCreation.warningAll")); + } -
+ @if (Model.IsAssetStoreFtp) + { + RenderRuleAsWarning(T.Get("setup.ruleFtp.warning")); + } -
- @Html.Raw(T.Get("setup.url.failure", new { actual = Model.BaseUrlCurrent, configured = Model.BaseUrlConfigured })) -
- } -
+ @if (Model.IsAssetStoreFile) + { + RenderRuleAsWarning(T.Get("setup.ruleFolder.warning")); + }

@@ -110,7 +142,7 @@
} - @if (Model.HasExternalLogin) + @if (Model.HasPasswordAuth) {

@T.Get("setup.createUser.headlineCreate")

@@ -166,4 +198,4 @@ @T.Get("setup.madeBy")
@T.Get("setup.madeByCopyright")
-
\ No newline at end of file +
diff --git a/backend/tests/Squidex.Web.Tests/Pipeline/RequestExceptionMiddlewareTests.cs b/backend/tests/Squidex.Web.Tests/Pipeline/RequestExceptionMiddlewareTests.cs index 2fb6f31a3..2339d07a3 100644 --- a/backend/tests/Squidex.Web.Tests/Pipeline/RequestExceptionMiddlewareTests.cs +++ b/backend/tests/Squidex.Web.Tests/Pipeline/RequestExceptionMiddlewareTests.cs @@ -24,7 +24,6 @@ namespace Squidex.Web.Pipeline private readonly IHttpResponseFeature responseFeature = A.Fake(); private readonly HttpContext httpContext = new DefaultHttpContext(); private readonly RequestDelegate next; - private readonly RequestExceptionMiddleware sut; private bool isNextCalled; public RequestExceptionMiddlewareTests() @@ -37,8 +36,6 @@ namespace Squidex.Web.Pipeline }; httpContext.Features.Set(responseFeature); - - sut = new RequestExceptionMiddleware(resultWriter, log); } [Fact] @@ -46,7 +43,9 @@ namespace Squidex.Web.Pipeline { httpContext.Request.QueryString = new QueryString("?error=412"); - await sut.InvokeAsync(httpContext, next); + var sut = new RequestExceptionMiddleware(next); + + await sut.InvokeAsync(httpContext, resultWriter, log); Assert.False(isNextCalled); @@ -60,7 +59,9 @@ namespace Squidex.Web.Pipeline { httpContext.Request.QueryString = new QueryString("?error=hello"); - await sut.InvokeAsync(httpContext, next); + var sut = new RequestExceptionMiddleware(next); + + await sut.InvokeAsync(httpContext, resultWriter, log); Assert.True(isNextCalled); @@ -73,7 +74,9 @@ namespace Squidex.Web.Pipeline { httpContext.Request.QueryString = new QueryString("?error=99"); - await sut.InvokeAsync(httpContext, next); + var sut = new RequestExceptionMiddleware(next); + + await sut.InvokeAsync(httpContext, resultWriter, log); Assert.True(isNextCalled); @@ -89,7 +92,9 @@ namespace Squidex.Web.Pipeline throw new InvalidOperationException(); }); - await sut.InvokeAsync(httpContext, failingNext); + var sut = new RequestExceptionMiddleware(failingNext); + + await sut.InvokeAsync(httpContext, resultWriter, log); A.CallTo(() => resultWriter.ExecuteAsync(A._, A.That.Matches(x => x.StatusCode == 500 && x.Value is ErrorDto))) @@ -106,7 +111,9 @@ namespace Squidex.Web.Pipeline throw ex; }); - await sut.InvokeAsync(httpContext, failingNext); + var sut = new RequestExceptionMiddleware(failingNext); + + await sut.InvokeAsync(httpContext, resultWriter, log); A.CallTo(() => log.Log(SemanticLogLevel.Error, ex, A._)) .MustHaveHappened(); @@ -123,7 +130,9 @@ namespace Squidex.Web.Pipeline throw new InvalidOperationException(); }); - await sut.InvokeAsync(httpContext, failingNext); + var sut = new RequestExceptionMiddleware(failingNext); + + await sut.InvokeAsync(httpContext, resultWriter, log); A.CallTo(() => resultWriter.ExecuteAsync(A._, A._)) .MustNotHaveHappened(); @@ -139,7 +148,9 @@ namespace Squidex.Web.Pipeline return Task.CompletedTask; }); - await sut.InvokeAsync(httpContext, failingNext); + var sut = new RequestExceptionMiddleware(failingNext); + + await sut.InvokeAsync(httpContext, resultWriter, log); A.CallTo(() => resultWriter.ExecuteAsync(A._, A.That.Matches(x => x.StatusCode == 412 && x.Value is ErrorDto))) @@ -159,7 +170,9 @@ namespace Squidex.Web.Pipeline return Task.CompletedTask; }); - await sut.InvokeAsync(httpContext, failingNext); + var sut = new RequestExceptionMiddleware(failingNext); + + await sut.InvokeAsync(httpContext, resultWriter, log); A.CallTo(() => resultWriter.ExecuteAsync(A._, A._)) .MustNotHaveHappened(); diff --git a/frontend/app/theme/_common.scss b/frontend/app/theme/_common.scss index a9048fc7b..028f9161a 100644 --- a/frontend/app/theme/_common.scss +++ b/frontend/app/theme/_common.scss @@ -239,6 +239,10 @@ body { color: inherit; } + &-warning { + background: $color-theme-orange; + } + &-failed { background: $color-theme-error; }