From 0155038ad73e5ecaa857b4712f31e6df44c0b4e4 Mon Sep 17 00:00:00 2001 From: Rui Lopes Date: Sat, 28 Mar 2020 12:26:41 +0000 Subject: [PATCH] hardcore the admin password to make this test environment easier to use --- README.md | 7 ++++--- provision/execute-provision.groovy-script.sh | 4 ++++ provision/nexus-groovy.sh | 2 +- provision/provision-nexus.sh | 3 +++ provision/provision-nexus/src/main/groovy/provision.groovy | 5 +++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83b3e14..7a00e17 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,10 @@ Add the following entry to your `/etc/hosts` file: Install Vagrant 2.1+. Run `vagrant up --provider=virtualbox # or --provider=libvirt` to launch the environment. -See its output to known how to login at the -[local Nexus home page](https://nexus.example.com) as `admin` (you can also login with -one of the example accounts, e.g. `alice.doe` and password `password`). + +Access the [Nexus home page](https://nexus.example.com) and login as the `admin` user and password `admin`. + +You can also login with one of the example accounts, e.g. `alice.doe` and password `password`. **NB** nginx is setup with a self-signed certificate that you have to trust before being able to access the local Nexus home page. diff --git a/provision/execute-provision.groovy-script.sh b/provision/execute-provision.groovy-script.sh index fb9fff7..67ad315 100644 --- a/provision/execute-provision.groovy-script.sh +++ b/provision/execute-provision.groovy-script.sh @@ -5,6 +5,10 @@ nexus_domain=$(hostname --fqdn) . /vagrant/provision/nexus-groovy.sh +# NB this is the default nexus password, which will be changed to +# 'admin' by the provision.groovy script that we run bellow. +admin_password='admin123' + # list existing scripts. #http -a "$admin_username:$admin_password" https://$nexus_domain/service/rest/v1/script | jq . diff --git a/provision/nexus-groovy.sh b/provision/nexus-groovy.sh index d055be4..dc589bb 100644 --- a/provision/nexus-groovy.sh +++ b/provision/nexus-groovy.sh @@ -2,7 +2,7 @@ set -eux admin_username=${admin_username:-admin} -admin_password=${admin_password:-$(cat /opt/nexus/sonatype-work/nexus3/admin.password)} +admin_password=${admin_password:-admin} # see https://help.sonatype.com/display/NXRM3/REST+and+Integration+API # see https://nexus.example.com/swagger-ui/ diff --git a/provision/provision-nexus.sh b/provision/provision-nexus.sh index 7626af4..aea4a8f 100644 --- a/provision/provision-nexus.sh +++ b/provision/provision-nexus.sh @@ -54,6 +54,9 @@ sed -i -E 's,nexus-pro-,nexus-oss-,g' sonatype-work/nexus3/etc/nexus.properties cat >>sonatype-work/nexus3/etc/nexus.properties <<'EOF' # disable the wizard. nexus.onboarding.enabled=false + +# disable generating a random password for the admin user. +nexus.security.randompassword=false EOF diff -u $nexus_home/etc/nexus-default.properties sonatype-work/nexus3/etc/nexus.properties || true popd diff --git a/provision/provision-nexus/src/main/groovy/provision.groovy b/provision/provision-nexus/src/main/groovy/provision.groovy index cc9f702..c87bf37 100644 --- a/provision/provision-nexus/src/main/groovy/provision.groovy +++ b/provision/provision-nexus/src/main/groovy/provision.groovy @@ -101,6 +101,11 @@ realmManager.enableRealm("NuGetApiKey") // enable the npm Bearer Token Realm. realmManager.enableRealm("NpmToken") +// set the admin password. +// NB we set it to something different than the default (admin123) to get +// rid of the "Default Admin Credentials" warning... and because this +// password is easier to remember. +security.securitySystem.changePassword('admin', 'admin') // the intent is to get or create an NuGet API Key like the one we can see on the user page: // http://nexus.example.com:8081/#user/nugetapitoken.