Skip to content

Commit

Permalink
Setup with saved password (#16466)
Browse files Browse the repository at this point in the history
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
  • Loading branch information
sarahelsaig and Piedone authored Jul 22, 2024
1 parent 757e40e commit 90062f7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">

<!-- Necessary as we reference the Project and not the Package -->
<Import Project="..\OrchardCore\OrchardCore.Application.Cms.Core.Targets\OrchardCore.Application.Cms.Core.Targets.props" />
Expand All @@ -10,6 +10,9 @@
<RazorRuntimeCompilation>false</RazorRuntimeCompilation>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- With this GUID, user secrets can be added with "dotnet user-secrets set key value" without further changes in
git. See an example use-case at https://docs.orchardcore.net/en/latest/reference/modules/AutoSetup/. -->
<UserSecretsId>2cfccf50-2ae4-4017-bbd7-a0e453cbf713</UserSecretsId>
</PropertyGroup>
<!-- For Unit Tests-->
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
var specialchar = new RegExp('[^A-Za-z0-9]');

var valid = false;
var $this = $(this);

createProgressBar(0, '');

Expand Down Expand Up @@ -71,14 +72,15 @@
target.append(el);
}

this.bind('keyup keydown', function (event) {
checkStrength($(this).val());
this.bind('keyup keydown change', function (event) {
checkStrength($this.val());
});
this.bind('drop', function (event) {
checkStrength(event.originalEvent.dataTransfer.getData("text"));
});

this.parents('form').on('submit', function () {
checkStrength($this.val());
if (!valid) {
event.preventDefault();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16199,6 +16199,7 @@ function togglePasswordVisibility(passwordCtl, togglePasswordCtl) {
var number = new RegExp('[0-9]');
var specialchar = new RegExp('[^A-Za-z0-9]');
var valid = false;
var $this = $(this);
createProgressBar(0, '');
function getPercentage(a, b) {
return (b / a * 100).toFixed(0);
Expand Down Expand Up @@ -16233,13 +16234,14 @@ function togglePasswordVisibility(passwordCtl, togglePasswordCtl) {
target.empty();
target.append(el);
}
this.bind('keyup keydown', function (event) {
checkStrength($(this).val());
this.bind('keyup keydown change', function (event) {
checkStrength($this.val());
});
this.bind('drop', function (event) {
checkStrength(event.originalEvent.dataTransfer.getData("text"));
});
this.parents('form').on('submit', function () {
checkStrength($this.val());
if (!valid) {
event.preventDefault();
}
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/docs/guides/gulp-pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The way you typically execute the Gulp tasks depends on whether you are using Vi
3. Navigate to the Orchard Core solution folder where the file `gulpfile.js` is located.
4. Execute one of the commands `gulp build`, `gulp rebuild` and `gulp watch` to execute the corresponding Gulp task.

Note: If Gulp fails on your system, try downgrading to an older Node.js version. If you are using [Node Version Manager](https://github.com/nvm-sh/nvm) ([for Windows](https://github.com/coreybutler/nvm-windows)) you can type `nvm install 18` or `nvm use 18` to switch to the latest version of Node.js 18.

### Using Visual Studio

Visual Studio 2022 and later comes with a built-in tool window named **Task Runner Explorer** that can be used to execute NPM tasks as well as tasks from different task runners such as Gulp and Grunt among others.
Expand Down
23 changes: 21 additions & 2 deletions src/docs/reference/modules/AutoSetup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,28 @@ Auto-Setup parameters are defined in appsettings.json. Example excerpt:
`/autosetup` - trigger installation of the Root tenant.
`/mytenant/autosetup` - auto-install mytenant.

### Environment Variables
### User Secrets and Environment Variables

If your JSON configuration contains sensitive information, or you don't want to commit it to the repository (because e.g. Auto Setup is not utilized by the whole development team), it is recommended to use user secrets or environment variables instead.

[User secrets](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets#secret-manager) are available during local development, and they are stored as JSON files. This means you can move the whole configuration from `appsettings.json` as-is. Alternatively, you can set each option directly from the command line (this will flatten any existing structures in the `secrets.json` file):

```shell
cd src/OrchardCore.Cms.Web
dotnet user-secrets init
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:ShellName" "Default"
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:SiteName" "AutoSetup Example"
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:SiteTimeZone" "Europe/Amsterdam"
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:AdminUsername" "admin"
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:AdminEmail" "info@orchardproject.net"
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:AdminPassword" "OrchardCoreRules1!"
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:RecipeName" "SaaS"
dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:DatabaseProvider" "Sqlite"
```

If you use a setup like the above when working with the full source code of Orchard Core, then all copies of the source will use it, due to `OrchardCore.Cms.Web` having `UserSecretsId` pre-configured. This is really useful when contributing to Orchard Core. However, if you want to remove this functionality, just remove the `UserSecretsId` element from the given copy's `OrchardCore.Cms.Web.csproj`.

Since JSON configuration contains admin-sensitive information, it is recommended to use environment variables instead.
[Environment variables](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration#non-prefixed-environment-variables) are available on both server and local machine. But if you have multiple projects, you have to prefix them to avoid clashes.

```
"OrchardCore__OrchardCore_AutoSetup__AutoSetupPath": ""
Expand Down

0 comments on commit 90062f7

Please sign in to comment.