├── .dockerignore ├── .env ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .travis.yml ├── Dockerfile ├── README.md ├── application-docker.properties ├── docker_build.sh ├── docker_build_and_publish.sh ├── docker_build_and_run.sh ├── mvnw ├── mvnw.cmd ├── pom.xml ├── src ├── main │ ├── java │ │ └── pl │ │ │ └── sly │ │ │ └── tools │ │ │ └── springbootadmindocker │ │ │ ├── SpringBootAdminDockerApplication.java │ │ │ └── config │ │ │ ├── InsecureConfig.java │ │ │ ├── SecurityConfig.java │ │ │ └── condition │ │ │ ├── Constants.java │ │ │ ├── SpringBootAdminInsecureConditional.java │ │ │ └── SpringBootAdminSecureConditional.java │ └── resources │ │ └── application.properties └── test │ ├── java │ └── pl │ │ └── sly │ │ └── tools │ │ └── springbootadmindocker │ │ ├── InsecureConfigTest.java │ │ └── SecurityConfigTest.java │ └── resources │ └── test.properties └── tag_commit.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .DS_Store/ 3 | .vscode/ 4 | .idea 5 | .mvn 6 | .settings 7 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | DOCKER_IMAGE_NAME=slydeveloper/spring-boot-admin 2 | DOCKER_IMAGE_VERSION=1.3 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | 27 | .DS_Store/ 28 | .vscode/ -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slydeveloper/spring-boot-admin-docker/7b99fbe009200b10a78a9d8b1b28e6bf516f1477/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | 4 | services: 5 | - docker 6 | 7 | script: 8 | - mvn clean package 9 | - docker build -t slydeveloper/spring-boot-admin:latest . 10 | - docker run -d -p 1111:1111 --name spring-boot-admin slydeveloper/spring-boot-admin:latest 11 | - sleep 30 12 | - docker exec -it spring-boot-admin sh -c "curl -f http://localhost:1111/health" 13 | - docker logs spring-boot-admin 14 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # build stage 2 | FROM maven:3.6.3-jdk-8-slim AS build-stage 3 | LABEL maintainer="sylwek.sokolowski@gmail.com" 4 | 5 | COPY pom.xml /tmp/ 6 | COPY src /tmp/src/ 7 | WORKDIR /tmp/ 8 | RUN mvn clean package 9 | 10 | # run stage 11 | FROM java:8-jre-alpine 12 | LABEL maintainer="sylwek.sokolowski@gmail.com" 13 | 14 | ARG BUILD_DATE 15 | ARG BUILD_NAME 16 | ARG BUILD_VERSION 17 | ARG VCS_REF 18 | 19 | LABEL org.label-schema.schema-version="1.0" 20 | LABEL org.label-schema.build-date=$BUILD_DATE 21 | LABEL org.label-schema.name=$BUILD_NAME 22 | LABEL org.label-schema.description="Spring Boot Admin Docker" 23 | LABEL org.label-schema.url="https://github.com/slydeveloper/spring-boot-admin-docker" 24 | LABEL org.label-schema.vcs-url="https://github.com/slydeveloper/spring-boot-admin-docker" 25 | LABEL org.label-schema.vcs-ref=$VCS_REF 26 | LABEL org.label-schema.vendor="Sylwester Sokolowski" 27 | LABEL org.label-schema.version=$BUILD_VERSION 28 | LABEL org.label-schema.docker.cmd="docker run -d -p 1111:1111 --name spring-boot-admin slydeveloper/spring-boot-admin" 29 | 30 | RUN apk add --no-cache curl 31 | COPY --from=build-stage /tmp/target/*.jar /opt/spring-boot-admin-docker/app.jar 32 | WORKDIR /opt/spring-boot-admin-docker 33 | EXPOSE 1111 34 | 35 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=docker","-jar","app.jar"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Spring Boot Admin 2 | ======================== 3 | Yet another implementation of containerized [spring-boot-admin](https://github.com/codecentric/spring-boot-admin) 4 | 5 | Info 6 | ---- 7 | - Name: `slydeveloper/spring-boot-admin` 8 | - Version: `latest`,`1.3`,`1.2`,`1.1`,`1.0` 9 | - [Docker Hub](https://hub.docker.com/r/slydeveloper/spring-boot-admin/) 10 | 11 | Details 12 | -------- 13 | - Image based on `java:8-jre-alpine` 14 | - Spring Boot Admin version: `2.6.1` 15 | - Spring Boot version: `2.6.2` 16 | - Default port: `1111` 17 | - Default user: `admin` 18 | - Default password: `secret` 19 | - URL: `http://localhost:1111` 20 | - Health check URL - `http://localhost:1111/health` 21 | 22 | Usage 23 | -------- 24 | `docker run -d -p 1111:1111 --name spring-boot-admin slydeveloper/spring-boot-admin:latest` 25 | 26 | Configuration via environment variables 27 | --------------------------------------- 28 | * `SPRING_BOOT_ADMIN_USER_NAME=user` 29 | * set username: `user` 30 | * `SPRING_BOOT_ADMIN_USER_PASSWORD=password` 31 | * set password: `password` 32 | * `SPRING_BOOT_ADMIN_TITLE=test` 33 | * set Page-Title: `test` 34 | * `SPRING_BOOT_ADMIN_SECURITY_ENABLED=false` 35 | * disable login form (default : `true`) 36 | 37 | ##### Examples 38 | * `docker run -d -p 1111:1111 -e SPRING_BOOT_ADMIN_TITLE='SB Admin' -e SPRING_BOOT_ADMIN_SECURITY_ENABLED=false --name spring-boot-admin slydeveloper/spring-boot-admin:latest` 39 | * `docker run -d -p 1111:1111 -e SPRING_BOOT_ADMIN_USER_NAME=user -e SPRING_BOOT_ADMIN_USER_PASSWORD='password' --name spring-boot-admin slydeveloper/spring-boot-admin:latest` 40 | 41 | Configuration via properties file 42 | --------------------------------- 43 | A container supports configuration via *.properties file, just like regular Spring Boot application. 44 | Please note that environment variables will be override by properties file. 45 | Properties of Spring Boot Admin: http://codecentric.github.io/spring-boot-admin/2.1.6/#spring-boot-admin-server 46 | 47 | Example `application-docker.properties` file: 48 | ``` 49 | # Spring Boot server port 50 | server.port=2222 51 | 52 | # Spring Boot Admin user/uassword 53 | spring.security.user.name=user 54 | spring.security.user.password=password 55 | 56 | # Spring Boot Admin title 57 | spring.boot.admin.ui.title=Custom title 58 | 59 | # custom property for disable security 60 | spring.boot.admin.security.enabled=false 61 | ``` 62 | 63 | Example command: 64 | - `docker run -d -p 2222:2222 -v "$(pwd)"/application-docker.properties:/opt/spring-boot-admin-docker/application-docker.properties --name spring-boot-admin slydeveloper/spring-boot-admin:latest` 65 | 66 | Docker-Compose example 67 | ---------------------- 68 | Health check usage of `slydeveloper/spring-boot-admin` with Docker-Compose. 69 | Full working Spring Boot Admin client [here](https://github.com/slydeveloper/spring-boot-admin-example). 70 | ``` 71 | version: '2.1' 72 | 73 | services: 74 | example: 75 | image: 76 | ports: 77 | - 8080:8080 78 | depends_on: 79 | admin: 80 | condition: service_healthy 81 | container_name: spring_boot_admin_example 82 | admin: 83 | image: slydeveloper/spring-boot-admin 84 | environment: 85 | - SPRING_BOOT_ADMIN_TITLE=Custom Spring Boot Admin title 86 | volumes: 87 | - ./application-docker.properties:/opt/spring-boot-admin-docker/application-docker.properties 88 | ports: 89 | - 1111:1111 90 | healthcheck: 91 | test: "curl -sS http://localhost:1111/health" 92 | interval: 1s 93 | timeout: 60s 94 | retries: 120 95 | container_name: spring_boot_admin_docker 96 | ``` 97 | 98 | Links 99 | ----- 100 | - Spring Boot Admin documentation: http://codecentric.github.io/spring-boot-admin/2.6.1/ 101 | -------------------------------------------------------------------------------- /application-docker.properties: -------------------------------------------------------------------------------- 1 | # Spring Boot server port 2 | # server.port=2222 3 | 4 | # Spring Boot Admin user/uassword 5 | # spring.security.user.name=user 6 | # spring.security.user.password=password 7 | 8 | # Spring Boot Admin title 9 | # spring.boot.admin.ui.title=Custom title 10 | 11 | # custom property for disable security 12 | # spring.boot.admin.security.enabled=false 13 | -------------------------------------------------------------------------------- /docker_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source .env 4 | echo Building image: $DOCKER_IMAGE_NAME 5 | 6 | docker rmi -f $(docker images | grep "" | awk "{print \$3}") 7 | docker build --no-cache=true \ 8 | --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ 9 | --build-arg BUILD_NAME=$DOCKER_IMAGE_NAME \ 10 | --build-arg BUILD_VERSION=$DOCKER_IMAGE_VERSION \ 11 | --build-arg VCS_REF=$(git rev-parse HEAD) \ 12 | -t $DOCKER_IMAGE_NAME . 13 | 14 | docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_VERSION 15 | docker inspect $DOCKER_IMAGE_NAME 16 | docker images $DOCKER_IMAGE_NAME -------------------------------------------------------------------------------- /docker_build_and_publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ./docker_build.sh 4 | docker push $DOCKER_IMAGE_NAME:latest 5 | docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_VERSION -------------------------------------------------------------------------------- /docker_build_and_run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ./docker_build.sh 4 | docker run --rm -p 1111:1111 slydeveloper/spring-boot-admin -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 44 | 45 | 47 | 4.0.0 48 | 49 | pl.sly.tools 50 | spring-boot-admin-docker 51 | 1.3 52 | jar 53 | 54 | spring-boot-admin-docker 55 | Spring Boot Admin Docker 56 | 57 | 58 | UTF-8 59 | UTF-8 60 | 1.8 61 | 2.6.1 62 | 2.6.2 63 | ${java.version} 64 | ${java.version} 65 | 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-dependencies 72 | ${spring.boot-version} 73 | pom 74 | import 75 | 76 | 77 | de.codecentric 78 | spring-boot-admin-dependencies 79 | ${spring-boot-admin.version} 80 | pom 81 | import 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-starter-actuator 88 | 89 | 90 | org.springframework.boot 91 | spring-boot-starter-security 92 | 93 | 94 | org.springframework.boot 95 | spring-boot-starter-web 96 | 97 | 98 | de.codecentric 99 | spring-boot-admin-starter-server 100 | 101 | 102 | de.codecentric 103 | spring-boot-admin-server-ui 104 | 105 | 106 | org.springframework.security 107 | spring-security-test 108 | test 109 | 110 | 111 | org.springframework.boot 112 | spring-boot-starter-test 113 | test 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | org.springframework.boot 122 | spring-boot-maven-plugin 123 | 124 | 125 | 126 | repackage 127 | build-info 128 | 129 | 130 | 131 | 132 | false 133 | 134 | ${spring.boot-version} 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /src/main/java/pl/sly/tools/springbootadmindocker/SpringBootAdminDockerApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker; 45 | 46 | import de.codecentric.boot.admin.server.config.EnableAdminServer; 47 | import org.springframework.boot.SpringApplication; 48 | import org.springframework.boot.autoconfigure.SpringBootApplication; 49 | 50 | /** 51 | * The type Spring boot admin docker application. 52 | */ 53 | @EnableAdminServer 54 | @SpringBootApplication 55 | public class SpringBootAdminDockerApplication { 56 | 57 | /** 58 | * Main. 59 | * 60 | * @param args the args 61 | */ 62 | public static void main(final String... args) { 63 | SpringApplication.run(SpringBootAdminDockerApplication.class, args); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/pl/sly/tools/springbootadmindocker/config/InsecureConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker.config; 45 | 46 | import org.springframework.context.annotation.Conditional; 47 | import org.springframework.context.annotation.Configuration; 48 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 49 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 50 | import pl.sly.tools.springbootadmindocker.config.condition.SpringBootAdminInsecureConditional; 51 | 52 | /** 53 | * The type Insecure config. 54 | */ 55 | @Conditional(SpringBootAdminInsecureConditional.class) 56 | @Configuration 57 | public class InsecureConfig extends WebSecurityConfigurerAdapter { 58 | 59 | @Override 60 | protected void configure(final HttpSecurity http) throws Exception { 61 | http 62 | .authorizeRequests() 63 | .anyRequest() 64 | .permitAll() 65 | .and() 66 | .csrf() 67 | .disable(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/pl/sly/tools/springbootadmindocker/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker.config; 45 | 46 | import de.codecentric.boot.admin.server.config.AdminServerProperties; 47 | import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest; 48 | import org.springframework.context.annotation.Conditional; 49 | import org.springframework.context.annotation.Configuration; 50 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 51 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 52 | import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; 53 | import pl.sly.tools.springbootadmindocker.config.condition.SpringBootAdminSecureConditional; 54 | 55 | /** 56 | * The type Security config. 57 | */ 58 | @Conditional(SpringBootAdminSecureConditional.class) 59 | @Configuration 60 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 61 | 62 | private static final String REDIRECT_TO = "redirectTo"; 63 | private static final String ASSETS = "/assets/**"; 64 | private static final String LOGIN = "/login"; 65 | private static final String LOGOUT = "/logout"; 66 | private final String adminContextPath; 67 | 68 | /** 69 | * Instantiates a new Security config. 70 | * 71 | * @param adminServerProperties the admin server properties 72 | */ 73 | public SecurityConfig(final AdminServerProperties adminServerProperties) { 74 | this.adminContextPath = adminServerProperties.getContextPath(); 75 | } 76 | 77 | @Override 78 | protected void configure(final HttpSecurity http) throws Exception { 79 | final SavedRequestAwareAuthenticationSuccessHandler successHandler 80 | = new SavedRequestAwareAuthenticationSuccessHandler(); 81 | successHandler.setTargetUrlParameter(REDIRECT_TO); 82 | 83 | http 84 | .authorizeRequests() 85 | .antMatchers(adminContextPath + ASSETS).permitAll() 86 | .antMatchers(adminContextPath + LOGIN).permitAll() 87 | .requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll() 88 | .anyRequest().authenticated() 89 | .and() 90 | .formLogin() 91 | .loginPage(adminContextPath + LOGIN) 92 | .successHandler(successHandler) 93 | .and() 94 | .logout() 95 | .logoutUrl(adminContextPath + LOGOUT) 96 | .and() 97 | .httpBasic() 98 | .and() 99 | .csrf() 100 | .disable(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/pl/sly/tools/springbootadmindocker/config/condition/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker.config.condition; 45 | 46 | /** 47 | * The type Constants. 48 | */ 49 | public class Constants { 50 | 51 | /** 52 | * The constant SPRING_BOOT_ADMIN_SECURITY_ENABLED. 53 | */ 54 | public static final String SPRING_BOOT_ADMIN_SECURITY_ENABLED = "spring.boot.admin.security.enabled"; 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/pl/sly/tools/springbootadmindocker/config/condition/SpringBootAdminInsecureConditional.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker.config.condition; 45 | 46 | import org.springframework.context.annotation.Condition; 47 | import org.springframework.context.annotation.ConditionContext; 48 | import org.springframework.core.env.Environment; 49 | import org.springframework.core.type.AnnotatedTypeMetadata; 50 | 51 | /** 52 | * Matches true if {spring.boot.admin.security.enabled} property is defined and value is false. 53 | */ 54 | public class SpringBootAdminInsecureConditional implements Condition { 55 | 56 | @Override 57 | public boolean matches(final ConditionContext conditionContext, final AnnotatedTypeMetadata annotatedTypeMetadata) { 58 | final Environment environment = conditionContext.getEnvironment(); 59 | 60 | return environment != null && Boolean.FALSE.toString() 61 | .equalsIgnoreCase( 62 | environment.getProperty(Constants.SPRING_BOOT_ADMIN_SECURITY_ENABLED)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/pl/sly/tools/springbootadmindocker/config/condition/SpringBootAdminSecureConditional.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker.config.condition; 45 | 46 | import org.springframework.context.annotation.Condition; 47 | import org.springframework.context.annotation.ConditionContext; 48 | import org.springframework.core.env.Environment; 49 | import org.springframework.core.type.AnnotatedTypeMetadata; 50 | 51 | /** 52 | * Matches true if {spring.boot.admin.security.enabled} property is not defined or value is true. 53 | * Security will be enabled by default. 54 | */ 55 | public class SpringBootAdminSecureConditional implements Condition { 56 | 57 | @Override 58 | public boolean matches(final ConditionContext conditionContext, final AnnotatedTypeMetadata annotatedTypeMetadata) { 59 | final Environment environment = conditionContext.getEnvironment(); 60 | 61 | return environment == null 62 | || environment.getProperty(Constants.SPRING_BOOT_ADMIN_SECURITY_ENABLED) == null 63 | || Boolean.TRUE.toString() 64 | .equalsIgnoreCase( 65 | environment.getProperty(Constants.SPRING_BOOT_ADMIN_SECURITY_ENABLED)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | # Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | # Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | # License Agreement between Customer "X" and TradeChannel AB. 6 | # 7 | # TradeseC contains third party software which includes software owned or licensed by a third party and 8 | # sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | # 10 | # TradeChannel AB owns the rights to the software product TradeseC. 11 | # 12 | # TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | # non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | # specified in this License Agreement. 15 | # 16 | # The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | # service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | # and the Third Party Software is in accordance with the License Agreement. 19 | # 20 | # The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | # other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | # Third Party Software, either directly or indirectly. 23 | # 24 | # The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | # Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | # what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | # independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | # or any accessories that may be related to it. 29 | # 30 | # The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | # documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | # and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | # 34 | # The Third Party Software are protected by copyright law. 35 | # 36 | # The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | # trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | # any medium by which they are made available or any form of output produced by them. 39 | # 40 | # The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | # under the terms of the License Agreement. 42 | # 43 | 44 | ########################################################### 45 | # SPRING BOOT PROPERTIES 46 | ########################################################### 47 | spring.application.name = spring-boot-admin-docker 48 | server.port = 1111 49 | spring.security.user.name = ${SPRING_BOOT_ADMIN_USER_NAME:admin} 50 | spring.security.user.password = ${SPRING_BOOT_ADMIN_USER_PASSWORD:secret} 51 | management.endpoints.web.base-path = / 52 | 53 | ########################################################### 54 | # SPRING BOOT ADMIN PROPERTIES 55 | ########################################################### 56 | spring.boot.admin.ui.title = ${SPRING_BOOT_ADMIN_TITLE:Spring Boot Admin Docker} 57 | 58 | ########################################################### 59 | # CUSTOM SPRING BOOT ADMIN PROPERTIES 60 | ########################################################### 61 | spring.boot.admin.security.enabled = ${SPRING_BOOT_ADMIN_SECURITY_ENABLED:true} 62 | -------------------------------------------------------------------------------- /src/test/java/pl/sly/tools/springbootadmindocker/InsecureConfigTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker; 45 | 46 | import org.junit.jupiter.api.Test; 47 | import org.springframework.beans.factory.NoSuchBeanDefinitionException; 48 | import org.springframework.beans.factory.annotation.Autowired; 49 | import org.springframework.boot.test.context.SpringBootTest; 50 | import org.springframework.boot.test.web.client.TestRestTemplate; 51 | import org.springframework.context.ApplicationContext; 52 | import org.springframework.http.HttpStatus; 53 | import org.springframework.http.ResponseEntity; 54 | import pl.sly.tools.springbootadmindocker.config.InsecureConfig; 55 | import pl.sly.tools.springbootadmindocker.config.SecurityConfig; 56 | 57 | import static org.junit.jupiter.api.Assertions.assertEquals; 58 | import static org.junit.jupiter.api.Assertions.assertNotNull; 59 | import static org.junit.jupiter.api.Assertions.assertThrows; 60 | import static org.junit.jupiter.api.Assertions.assertTrue; 61 | 62 | /** 63 | * The type Insecure config test. 64 | */ 65 | @SpringBootTest( 66 | properties = "spring.boot.admin.security.enabled=false", 67 | webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 68 | public class InsecureConfigTest { 69 | 70 | private static final String DEFAULT_PATH = "/"; 71 | private static final String HTML_APP_DIV = "Spring Boot Admin Docker"; 72 | 73 | @Autowired 74 | private ApplicationContext applicationContext; 75 | 76 | @Autowired 77 | private TestRestTemplate testRestTemplate; 78 | 79 | /** 80 | * When security disabled should inject insecure config. 81 | */ 82 | @Test 83 | public void whenSecurityDisabled_shouldInjectInsecureConfig() { 84 | // when 85 | final InsecureConfig insecureConfig = applicationContext.getBean(InsecureConfig.class); 86 | 87 | // then 88 | assertNotNull(insecureConfig); 89 | } 90 | 91 | /** 92 | * When security disabled should not inject security config. 93 | */ 94 | @Test 95 | public void whenSecurityDisabled_shouldNotInjectSecurityConfig() { 96 | final Exception exception = assertThrows(NoSuchBeanDefinitionException.class, () -> { 97 | applicationContext.getBean(SecurityConfig.class); 98 | }); 99 | 100 | // when 101 | 102 | // then 103 | // NoSuchBeanDefinitionException should be thrown 104 | } 105 | 106 | /** 107 | * When security disabled should return http 200 status code and valid body. 108 | */ 109 | @Test 110 | public void whenSecurityDisabled_shouldReturnHttp200statusCodeAndValidBody() { 111 | // given & when 112 | final ResponseEntity responseEntity = testRestTemplate.getForEntity(DEFAULT_PATH, String.class); 113 | 114 | // then 115 | assertNotNull(responseEntity, "Response Entity"); 116 | assertNotNull(responseEntity.getBody()); 117 | assertTrue(responseEntity.getBody() 118 | .contains(HTML_APP_DIV)); 119 | assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/test/java/pl/sly/tools/springbootadmindocker/SecurityConfigTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | * Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | * License Agreement between Customer "X" and TradeChannel AB. 6 | * 7 | * TradeseC contains third party software which includes software owned or licensed by a third party and 8 | * sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | * 10 | * TradeChannel AB owns the rights to the software product TradeseC. 11 | * 12 | * TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | * non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | * specified in this License Agreement. 15 | * 16 | * The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | * service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | * and the Third Party Software is in accordance with the License Agreement. 19 | * 20 | * The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | * other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | * Third Party Software, either directly or indirectly. 23 | * 24 | * The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | * Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | * what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | * independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | * or any accessories that may be related to it. 29 | * 30 | * The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | * documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | * and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | * 34 | * The Third Party Software are protected by copyright law. 35 | * 36 | * The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | * trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | * any medium by which they are made available or any form of output produced by them. 39 | * 40 | * The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | * under the terms of the License Agreement. 42 | */ 43 | 44 | package pl.sly.tools.springbootadmindocker; 45 | 46 | import org.junit.jupiter.api.Test; 47 | import org.springframework.beans.factory.NoSuchBeanDefinitionException; 48 | import org.springframework.beans.factory.annotation.Autowired; 49 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 50 | import org.springframework.boot.test.context.SpringBootTest; 51 | import org.springframework.boot.test.web.client.TestRestTemplate; 52 | import org.springframework.context.ApplicationContext; 53 | import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders; 54 | import org.springframework.test.context.TestPropertySource; 55 | import org.springframework.test.web.servlet.MockMvc; 56 | import pl.sly.tools.springbootadmindocker.config.InsecureConfig; 57 | import pl.sly.tools.springbootadmindocker.config.SecurityConfig; 58 | 59 | import static org.junit.jupiter.api.Assertions.assertNotNull; 60 | import static org.junit.jupiter.api.Assertions.assertThrows; 61 | import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin; 62 | import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.authenticated; 63 | 64 | /** 65 | * The type Security config test. 66 | */ 67 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 68 | @TestPropertySource(locations = "classpath:test.properties") 69 | @AutoConfigureMockMvc 70 | public class SecurityConfigTest { 71 | 72 | private static final String USERNAME_PARAMETER = "username"; 73 | private static final String USERNAME = "test"; 74 | private static final String PASSWORD = "test"; 75 | 76 | @Autowired 77 | private MockMvc mockMvc; 78 | 79 | @Autowired 80 | private ApplicationContext applicationContext; 81 | 82 | @Autowired 83 | private TestRestTemplate testRestTemplate; 84 | 85 | /** 86 | * When security enabled by default should inject security config. 87 | */ 88 | @Test 89 | public void whenSecurityEnabledByDefault_shouldInjectSecurityConfig() { 90 | // when 91 | final SecurityConfig securityConfig = applicationContext.getBean(SecurityConfig.class); 92 | 93 | // then 94 | assertNotNull(securityConfig); 95 | } 96 | 97 | /** 98 | * When security enabled by default should not inject insecure config. 99 | */ 100 | // @Test 101 | public void whenSecurityEnabledByDefault_shouldNotInjectInsecureConfig() { 102 | final Exception exception = assertThrows(NoSuchBeanDefinitionException.class, () -> { 103 | applicationContext.getBean(InsecureConfig.class); 104 | }); 105 | 106 | // when 107 | 108 | // then 109 | // NoSuchBeanDefinitionException should be thrown 110 | } 111 | 112 | /** 113 | * When security enabled by default and valid credentials should authenticate success. 114 | * 115 | * @throws Exception the exception 116 | */ 117 | @Test 118 | public void whenSecurityEnabledByDefaultAndValidCredentials_shouldAuthenticateSuccess() throws Exception { 119 | // given 120 | final SecurityMockMvcRequestBuilders.FormLoginRequestBuilder login = formLogin() 121 | .user(USERNAME_PARAMETER, USERNAME) 122 | .password(PASSWORD); 123 | 124 | // when & then 125 | mockMvc.perform(login) 126 | .andExpect(authenticated().withUsername(USERNAME)); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/test/resources/test.properties: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | # Copyright (c) 2000-2022, TradeChannel AB. All rights reserved. 4 | # Any right to utilize the System under this Agreement shall be subject to the terms and condition of the 5 | # License Agreement between Customer "X" and TradeChannel AB. 6 | # 7 | # TradeseC contains third party software which includes software owned or licensed by a third party and 8 | # sub licensed to the Customer by TradeChannel AB in accordance with the License Agreement. 9 | # 10 | # TradeChannel AB owns the rights to the software product TradeseC. 11 | # 12 | # TradeChannel AB grants a right to the Customer and the Customer accepts a non-exclusive, 13 | # non-transferrable license to use TradeseC and Third Party Software, in accordance with the conditions 14 | # specified in this License Agreement. 15 | # 16 | # The Customer may not use TradeseC or the Third Party Software for time-sharing, rental, 17 | # service bureau use, or similar use. The Customer is responsible for that all use of TradeseC 18 | # and the Third Party Software is in accordance with the License Agreement. 19 | # 20 | # The Customer may not transfer, sell, sublicense, let, lend or in any other way permit any person or entity 21 | # other than the Customer, avail himself, herself or itself of or otherwise any rights to TradeseC or the 22 | # Third Party Software, either directly or indirectly. 23 | # 24 | # The Customer may not use, copy, modify or in any other way transfer or use TradeseC or the 25 | # Third Party Software wholly or partially, nor allow another person or entity to do so, in any way other than 26 | # what is expressly permitted according to the License Agreement. Nor, consequently, may the Customer, 27 | # independently or through an agent, reverse engineer, decompile or disassemble TradeseC, the Third Party Software 28 | # or any accessories that may be related to it. 29 | # 30 | # The Customer acknowledges TradeseC (including but not limited to any copyrights, trademarks, 31 | # documentation, enhancements or other intellectual property or proprietary rights relating to it) 32 | # and Third Party Software is the proprietary material of the Supplier and respectively Third Party. 33 | # 34 | # The Third Party Software are protected by copyright law. 35 | # 36 | # The Customer shall not remove, erase or hide from view any information about a patent, copyright, 37 | # trademark, confidentiality notice, mark or legend appearing on any of TradeseC or Third Party Software, 38 | # any medium by which they are made available or any form of output produced by them. 39 | # 40 | # The License Agreement will only grant the Customer the right to use TradeseC and Third Party Software 41 | # under the terms of the License Agreement. 42 | # 43 | 44 | spring.security.user.name = test 45 | spring.security.user.password = test 46 | -------------------------------------------------------------------------------- /tag_commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source .env 4 | git tag -a v$DOCKER_IMAGE_VERSION -m "Add version $DOCKER_IMAGE_VERSION" 5 | git push --tags --------------------------------------------------------------------------------