├── .gitignore ├── LICENSE ├── README.md ├── api-gateway ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── euroka │ │ │ └── gateway │ │ │ ├── GatewayApplication.java │ │ │ └── SpringSecurityConfig.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── euroka │ └── gateway │ └── GatewayApplicationTests.java ├── docker-compose.yml ├── eureka-server ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── euroka │ │ │ └── eurekaserver │ │ │ └── EurekaServerApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── euroka │ └── eurekaserver │ └── EurekaServerApplicationTests.java ├── keycloak-server └── realm-export.json ├── microservice-consumer ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── euroka │ │ │ └── producer │ │ │ ├── ConsumerResourceApplication.java │ │ │ ├── OAuth2ResourceServerConfig.java │ │ │ └── TestController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── euroka │ └── producer │ └── ConsumerResourceApplicationTests.java ├── microservice-producer ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── euroka │ │ │ └── producer │ │ │ ├── OAuth2ResourceServerConfig.java │ │ │ ├── ProducerResourceApplication.java │ │ │ └── TestController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── euroka │ └── producer │ └── ProducerResourceApplicationTests.java └── pom.xml /.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/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Kunkka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-microservice-oauth2-keycloak-starter 2 | 3 | For detailed tutorial, please refer to the post. 4 | https://kunkkali.blogspot.com/2020/10/build-j2ee-micro-services-architecture.html 5 | 6 | ## docker-compose.yml 7 | Replace host ip inside with your own, then run the following cmd to start: 8 | 9 | `docker-compose up --build` 10 | 11 | Navigate to the following url, then Login keycloak with dev/123 12 | 13 | `localhost:8080/api/consume/` 14 | 15 | ## Fetch access token and refresh token from keycloak server 16 | Post a request to get an access token: 17 | 18 | `POST http://localhost:18080/auth/realms/spring-micro-main/protocol/openid-connect/token` 19 | `Content-Type: application/x-www-form-urlencoded` 20 | 21 | `&client_id=spring-micro-gateway&username=dev&password=123&grant_type=password&client_secret=756b0558-018b-4809-b478-bd5b4995d325` 22 | 23 | ## Test API 24 | Get request with bearer token: 25 | 26 | `GET localhost:8080/api/produce/` 27 | `Authorization: Bearer ` 28 | -------------------------------------------------------------------------------- /api-gateway/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ -------------------------------------------------------------------------------- /api-gateway/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /api-gateway/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liqili/spring-microservice-oauth2-keycloak-starter/bac24c284d8412a0b844ac4dbd90e4c43d375927/api-gateway/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /api-gateway/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /api-gateway/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine as mvn-build 2 | WORKDIR /app/build 3 | COPY ./src ./src 4 | COPY pom.xml . 5 | COPY .mvn .mvn 6 | COPY mvnw . 7 | RUN ./mvnw clean install -Dmaven.test.skip=true 8 | 9 | FROM openjdk:8-jre-alpine 10 | WORKDIR /app 11 | COPY --from=mvn-build /app/build/target/*.jar ./spring-app.jar 12 | CMD ["java", "-jar", "/app/spring-app.jar"] 13 | 14 | -------------------------------------------------------------------------------- /api-gateway/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 | # Maven 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 Mingw, 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 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /api-gateway/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 Maven 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 keystroke 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 set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /api-gateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.4.RELEASE 9 | 10 | 11 | com.euroka 12 | api-gateway 13 | 0.0.1-SNAPSHOT 14 | api-gateway 15 | API gateway 16 | 17 | 18 | 1.8 19 | Hoxton.SR8 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-client 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-gateway 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-oauth2-client 34 | 35 | 36 | org.springframework.cloud 37 | spring-cloud-starter-security 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-oauth2-resource-server 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-webflux 46 | 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-test 52 | test 53 | 54 | 55 | org.junit.vintage 56 | junit-vintage-engine 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.springframework.cloud 66 | spring-cloud-dependencies 67 | ${spring-cloud.version} 68 | pom 69 | import 70 | 71 | 72 | org.keycloak.bom 73 | keycloak-adapter-bom 74 | 11.0.0 75 | pom 76 | import 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/euroka/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.euroka.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaClient 9 | //@EnableOAuth2Sso 10 | public class GatewayApplication { 11 | public static void main(String[] args) { 12 | SpringApplication.run(GatewayApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/euroka/gateway/SpringSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.euroka.gateway; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity; 5 | import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; 6 | import org.springframework.security.config.web.server.ServerHttpSecurity; 7 | import org.springframework.security.web.server.SecurityWebFilterChain; 8 | 9 | @EnableWebFluxSecurity 10 | @EnableReactiveMethodSecurity 11 | public class SpringSecurityConfig { 12 | 13 | @Bean 14 | public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { 15 | // @formatter:off 16 | http 17 | .authorizeExchange() 18 | .anyExchange().authenticated() 19 | .and() 20 | .oauth2Login() 21 | .and() 22 | .oauth2ResourceServer() 23 | .jwt(); 24 | return http.build(); 25 | // @formatter:on 26 | } 27 | } -------------------------------------------------------------------------------- /api-gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | root: WARN 4 | org.springframework.web: INFO 5 | org.springframework.security: DEBUG 6 | org.springframework.security.oauth2: DEBUG 7 | 8 | server: 9 | port: 8080 10 | keycloak-client: 11 | server-url: http://localhost:18080/auth 12 | realm: spring-micro-main 13 | spring: 14 | application: 15 | name: api-gateway 16 | security: 17 | oauth2: 18 | client: 19 | registration: 20 | keycloak: 21 | provider: keycloak 22 | client-id: spring-micro-gateway 23 | client-secret: 756b0558-018b-4809-b478-bd5b4995d325 24 | authorization-grant-type: authorization_code 25 | redirect-uri: http://localhost:8080/login/oauth2/code/keycloak 26 | scope: openid 27 | provider: 28 | keycloak: 29 | authorization-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/auth 30 | token-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/token 31 | user-info-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/userinfo 32 | jwk-set-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/certs 33 | user-name-attribute: name 34 | user-info-authentication-method: header 35 | resourceserver: 36 | jwt: 37 | jwk-set-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/certs 38 | cloud: 39 | gateway: 40 | routes: 41 | - id: microservice-consumer 42 | uri: lb://microservice-consumer 43 | predicates: 44 | - Path=/api/consume/** 45 | filters: 46 | - TokenRelay= 47 | - RemoveRequestHeader=Cookie 48 | - id: microservice-producer 49 | uri: lb://microservice-producer 50 | predicates: 51 | - Path=/api/produce/** 52 | filters: 53 | - TokenRelay= 54 | - RemoveRequestHeader=Cookie 55 | 56 | eureka: 57 | client: 58 | serviceUrl: 59 | defaultZone: http://localhost:9091/eureka/ 60 | 61 | 62 | #zuul: 63 | # routes: 64 | # microservice-consumer: 65 | # serviceId: microservice-consumer 66 | # path: /api/consume/** -------------------------------------------------------------------------------- /api-gateway/src/test/java/com/euroka/gateway/GatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.euroka.gateway; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class GatewayApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | services: 3 | api-gateway: 4 | build: 5 | context: ./api-gateway 6 | ports: 7 | - "8080:8080" 8 | restart: on-failure 9 | environment: 10 | #overriding spring application.properties 11 | - eureka.client.serviceUrl.defaultZone=http://eureka-server:9091/eureka/ 12 | - keycloak-client.server-url=http://10.0.0.17:18080/auth # use host name or ip of the host machine 13 | depends_on: 14 | - eureka-server 15 | eureka-server: 16 | build: 17 | context: ./eureka-server 18 | ports: 19 | - "9091:9091" 20 | restart: on-failure 21 | microservice-consumer: 22 | build: 23 | context: ./microservice-consumer 24 | ports: 25 | - "9080:9080" 26 | restart: on-failure 27 | environment: 28 | #overriding spring application.properties 29 | - eureka.client.serviceUrl.defaultZone=http://eureka-server:9091/eureka/ 30 | - keycloak-client.server-url=http://10.0.0.17:18080/auth # use host name or ip of the host machine 31 | depends_on: 32 | - eureka-server 33 | microservice-producer: 34 | build: 35 | context: ./microservice-producer 36 | ports: 37 | - "9081:9081" 38 | restart: on-failure 39 | environment: 40 | #overriding spring application.properties 41 | - eureka.client.serviceUrl.defaultZone=http://eureka-server:9091/eureka/ 42 | - keycloak-client.server-url=http://10.0.0.17:18080/auth # use host name or ip of the host machine 43 | depends_on: 44 | - eureka-server 45 | keycloak: 46 | image: jboss/keycloak:11.0.0 47 | volumes: 48 | - ./keycloak-server/realm-export.json:/tmp/keycloak/config/realm-export.json 49 | environment: 50 | KEYCLOAK_USER: admin 51 | KEYCLOAK_PASSWORD: admin 52 | KEYCLOAK_IMPORT: /tmp/keycloak/config/realm-export.json 53 | DB_VENDOR: POSTGRES 54 | DB_ADDR: postgres 55 | DB_DATABASE: keycloak 56 | DB_USER: keycloak 57 | DB_SCHEMA: public 58 | DB_PASSWORD: password 59 | ports: 60 | - "18080:18080" 61 | command: 62 | - "-b" 63 | - "0.0.0.0" 64 | - "-Djboss.socket.binding.port-offset=10000" 65 | restart: on-failure 66 | depends_on: 67 | - postgres 68 | postgres: 69 | image: postgres 70 | volumes: 71 | - postgres_data:/var/lib/postgresql/data 72 | environment: 73 | POSTGRES_DB: keycloak 74 | POSTGRES_USER: keycloak 75 | POSTGRES_PASSWORD: password 76 | volumes: 77 | postgres_data: 78 | name: keycloak_postgres_data 79 | driver: local -------------------------------------------------------------------------------- /eureka-server/.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/ -------------------------------------------------------------------------------- /eureka-server/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /eureka-server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liqili/spring-microservice-oauth2-keycloak-starter/bac24c284d8412a0b844ac4dbd90e4c43d375927/eureka-server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /eureka-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /eureka-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine as mvn-build 2 | WORKDIR /app/build 3 | COPY ./src ./src 4 | COPY pom.xml . 5 | COPY .mvn .mvn 6 | COPY mvnw . 7 | RUN ./mvnw clean install -Dmaven.test.skip=true 8 | 9 | FROM openjdk:8-jre-alpine 10 | WORKDIR /app 11 | COPY --from=mvn-build /app/build/target/*.jar ./spring-app.jar 12 | CMD ["java", "-jar", "/app/spring-app.jar"] 13 | 14 | -------------------------------------------------------------------------------- /eureka-server/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 | # Maven 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 Mingw, 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 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /eureka-server/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 Maven 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 keystroke 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 set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /eureka-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.3.4.RELEASE 10 | 11 | 12 | com.euroka 13 | eureka-server 14 | 0.0.1-SNAPSHOT 15 | eureka-server 16 | Service registration 17 | 18 | 19 | 1.8 20 | Hoxton.SR8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-netflix-eureka-server 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-test 31 | test 32 | 33 | 34 | org.junit.vintage 35 | junit-vintage-engine 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-dependencies 46 | ${spring-cloud.version} 47 | pom 48 | import 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-maven-plugin 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /eureka-server/src/main/java/com/euroka/eurekaserver/EurekaServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.euroka.eurekaserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaServerApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /eureka-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=9091 2 | spring.application.name=eureka-server 3 | eureka.client.serviceUrl.defaultZone:http://localhost:9091/eureka/ 4 | eureka.client.register-with-eureka=false 5 | eureka.client.fetch-registry=false -------------------------------------------------------------------------------- /eureka-server/src/test/java/com/euroka/eurekaserver/EurekaServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.euroka.eurekaserver; 2 | 3 | import org.springframework.boot.test.context.SpringBootTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | 7 | @SpringBootTest 8 | public class EurekaServerApplicationTests { 9 | 10 | 11 | @Test 12 | public void contextLoads() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /keycloak-server/realm-export.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "spring-micro-main", 3 | "realm": "spring-micro-main", 4 | "notBefore": 0, 5 | "revokeRefreshToken": false, 6 | "refreshTokenMaxReuse": 0, 7 | "accessTokenLifespan": 300, 8 | "accessTokenLifespanForImplicitFlow": 900, 9 | "ssoSessionIdleTimeout": 1800, 10 | "ssoSessionMaxLifespan": 36000, 11 | "ssoSessionIdleTimeoutRememberMe": 0, 12 | "ssoSessionMaxLifespanRememberMe": 0, 13 | "offlineSessionIdleTimeout": 2592000, 14 | "offlineSessionMaxLifespanEnabled": false, 15 | "offlineSessionMaxLifespan": 5184000, 16 | "clientSessionIdleTimeout": 0, 17 | "clientSessionMaxLifespan": 0, 18 | "clientOfflineSessionIdleTimeout": 0, 19 | "clientOfflineSessionMaxLifespan": 0, 20 | "accessCodeLifespan": 60, 21 | "accessCodeLifespanUserAction": 300, 22 | "accessCodeLifespanLogin": 1800, 23 | "actionTokenGeneratedByAdminLifespan": 43200, 24 | "actionTokenGeneratedByUserLifespan": 300, 25 | "enabled": true, 26 | "sslRequired": "external", 27 | "registrationAllowed": false, 28 | "registrationEmailAsUsername": false, 29 | "rememberMe": false, 30 | "verifyEmail": false, 31 | "loginWithEmailAllowed": true, 32 | "duplicateEmailsAllowed": false, 33 | "resetPasswordAllowed": false, 34 | "editUsernameAllowed": false, 35 | "bruteForceProtected": false, 36 | "permanentLockout": false, 37 | "maxFailureWaitSeconds": 900, 38 | "minimumQuickLoginWaitSeconds": 60, 39 | "waitIncrementSeconds": 60, 40 | "quickLoginCheckMilliSeconds": 1000, 41 | "maxDeltaTimeSeconds": 43200, 42 | "failureFactor": 30, 43 | "roles": { 44 | "realm": [ 45 | { 46 | "id": "64581d8b-0427-406f-a0e3-6259304f8cea", 47 | "name": "offline_access", 48 | "description": "${role_offline-access}", 49 | "composite": false, 50 | "clientRole": false, 51 | "containerId": "spring-micro-main", 52 | "attributes": {} 53 | }, 54 | { 55 | "id": "b4ae8fcc-41fc-4663-aeb5-6e37da5a5c36", 56 | "name": "uma_authorization", 57 | "description": "${role_uma_authorization}", 58 | "composite": false, 59 | "clientRole": false, 60 | "containerId": "spring-micro-main", 61 | "attributes": {} 62 | } 63 | ], 64 | "client": { 65 | "spring-micro-producer": [], 66 | "realm-management": [ 67 | { 68 | "id": "20f0e81d-daf5-4361-b777-42de84ad2023", 69 | "name": "manage-realm", 70 | "description": "${role_manage-realm}", 71 | "composite": false, 72 | "clientRole": true, 73 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 74 | "attributes": {} 75 | }, 76 | { 77 | "id": "9a36e5c7-9a41-4338-8590-e342b74cdada", 78 | "name": "view-users", 79 | "description": "${role_view-users}", 80 | "composite": true, 81 | "composites": { 82 | "client": { 83 | "realm-management": [ 84 | "query-groups", 85 | "query-users" 86 | ] 87 | } 88 | }, 89 | "clientRole": true, 90 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 91 | "attributes": {} 92 | }, 93 | { 94 | "id": "ca57fe90-7e12-44cc-ac0e-c5fb3aa66159", 95 | "name": "realm-admin", 96 | "description": "${role_realm-admin}", 97 | "composite": true, 98 | "composites": { 99 | "client": { 100 | "realm-management": [ 101 | "manage-realm", 102 | "view-users", 103 | "view-realm", 104 | "query-realms", 105 | "query-clients", 106 | "view-authorization", 107 | "manage-clients", 108 | "query-users", 109 | "impersonation", 110 | "view-clients", 111 | "view-events", 112 | "manage-users", 113 | "manage-events", 114 | "query-groups", 115 | "create-client", 116 | "view-identity-providers", 117 | "manage-identity-providers", 118 | "manage-authorization" 119 | ] 120 | } 121 | }, 122 | "clientRole": true, 123 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 124 | "attributes": {} 125 | }, 126 | { 127 | "id": "c11bc707-2076-44fd-977b-f3f74d18c037", 128 | "name": "view-realm", 129 | "description": "${role_view-realm}", 130 | "composite": false, 131 | "clientRole": true, 132 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 133 | "attributes": {} 134 | }, 135 | { 136 | "id": "a6901023-54db-4a61-9b0f-2af8b212cf2d", 137 | "name": "query-realms", 138 | "description": "${role_query-realms}", 139 | "composite": false, 140 | "clientRole": true, 141 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 142 | "attributes": {} 143 | }, 144 | { 145 | "id": "34ae53ff-af69-4e12-b4ae-2b2c1ffe41bf", 146 | "name": "query-clients", 147 | "description": "${role_query-clients}", 148 | "composite": false, 149 | "clientRole": true, 150 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 151 | "attributes": {} 152 | }, 153 | { 154 | "id": "eeccf10a-e940-4284-aaf7-a894964ba662", 155 | "name": "view-authorization", 156 | "description": "${role_view-authorization}", 157 | "composite": false, 158 | "clientRole": true, 159 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 160 | "attributes": {} 161 | }, 162 | { 163 | "id": "775b3d13-01fc-42a5-a84a-9859d94e2c29", 164 | "name": "manage-clients", 165 | "description": "${role_manage-clients}", 166 | "composite": false, 167 | "clientRole": true, 168 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 169 | "attributes": {} 170 | }, 171 | { 172 | "id": "8839c339-88fb-48ad-9d39-8073d73322b9", 173 | "name": "query-users", 174 | "description": "${role_query-users}", 175 | "composite": false, 176 | "clientRole": true, 177 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 178 | "attributes": {} 179 | }, 180 | { 181 | "id": "dd3d1db3-ac52-4d2f-b948-33fb4e24ce2a", 182 | "name": "impersonation", 183 | "description": "${role_impersonation}", 184 | "composite": false, 185 | "clientRole": true, 186 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 187 | "attributes": {} 188 | }, 189 | { 190 | "id": "278b079f-1027-4de4-8056-891a5e680b10", 191 | "name": "view-clients", 192 | "description": "${role_view-clients}", 193 | "composite": true, 194 | "composites": { 195 | "client": { 196 | "realm-management": [ 197 | "query-clients" 198 | ] 199 | } 200 | }, 201 | "clientRole": true, 202 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 203 | "attributes": {} 204 | }, 205 | { 206 | "id": "17c3d76a-e8e3-4c27-bc80-1cc867cfb2c9", 207 | "name": "view-events", 208 | "description": "${role_view-events}", 209 | "composite": false, 210 | "clientRole": true, 211 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 212 | "attributes": {} 213 | }, 214 | { 215 | "id": "4453e150-a545-4d2f-893e-d96603e84e09", 216 | "name": "manage-users", 217 | "description": "${role_manage-users}", 218 | "composite": false, 219 | "clientRole": true, 220 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 221 | "attributes": {} 222 | }, 223 | { 224 | "id": "1e7528fa-2564-4f14-8480-b86590274519", 225 | "name": "manage-events", 226 | "description": "${role_manage-events}", 227 | "composite": false, 228 | "clientRole": true, 229 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 230 | "attributes": {} 231 | }, 232 | { 233 | "id": "28632ea7-8e41-4dee-9ee0-f9e9e8f373c4", 234 | "name": "query-groups", 235 | "description": "${role_query-groups}", 236 | "composite": false, 237 | "clientRole": true, 238 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 239 | "attributes": {} 240 | }, 241 | { 242 | "id": "e5d706e3-fc1c-4bc1-b6fb-3b6c325e9f12", 243 | "name": "create-client", 244 | "description": "${role_create-client}", 245 | "composite": false, 246 | "clientRole": true, 247 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 248 | "attributes": {} 249 | }, 250 | { 251 | "id": "6e90b3c2-aed3-47c8-9da6-1e9adbb63c3c", 252 | "name": "view-identity-providers", 253 | "description": "${role_view-identity-providers}", 254 | "composite": false, 255 | "clientRole": true, 256 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 257 | "attributes": {} 258 | }, 259 | { 260 | "id": "3f1a2429-5762-4795-acd4-3455d60a2caf", 261 | "name": "manage-identity-providers", 262 | "description": "${role_manage-identity-providers}", 263 | "composite": false, 264 | "clientRole": true, 265 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 266 | "attributes": {} 267 | }, 268 | { 269 | "id": "59649ab2-1e28-4d87-ae6b-5121c4de2e24", 270 | "name": "manage-authorization", 271 | "description": "${role_manage-authorization}", 272 | "composite": false, 273 | "clientRole": true, 274 | "containerId": "5cc089bb-0b35-4818-a951-617beede0e65", 275 | "attributes": {} 276 | } 277 | ], 278 | "spring-micro-gateway": [], 279 | "security-admin-console": [], 280 | "spring-micro-consumer": [], 281 | "admin-cli": [], 282 | "account-console": [], 283 | "broker": [ 284 | { 285 | "id": "f5d43f6e-8f43-4b31-aa22-876834b03d81", 286 | "name": "read-token", 287 | "description": "${role_read-token}", 288 | "composite": false, 289 | "clientRole": true, 290 | "containerId": "ac7ca518-46d5-49d2-ba3b-931034c725f8", 291 | "attributes": {} 292 | } 293 | ], 294 | "account": [ 295 | { 296 | "id": "22f58bed-e977-4bc7-8bc2-cbdd753328fa", 297 | "name": "manage-account", 298 | "description": "${role_manage-account}", 299 | "composite": true, 300 | "composites": { 301 | "client": { 302 | "account": [ 303 | "manage-account-links" 304 | ] 305 | } 306 | }, 307 | "clientRole": true, 308 | "containerId": "637d3007-a12d-49df-a028-f630822ccb03", 309 | "attributes": {} 310 | }, 311 | { 312 | "id": "6e693ae3-7606-4a7c-a55a-c5b96ae826b0", 313 | "name": "view-profile", 314 | "description": "${role_view-profile}", 315 | "composite": false, 316 | "clientRole": true, 317 | "containerId": "637d3007-a12d-49df-a028-f630822ccb03", 318 | "attributes": {} 319 | }, 320 | { 321 | "id": "cbcd1fba-4e45-40c2-8e38-587ae64a6f36", 322 | "name": "view-applications", 323 | "description": "${role_view-applications}", 324 | "composite": false, 325 | "clientRole": true, 326 | "containerId": "637d3007-a12d-49df-a028-f630822ccb03", 327 | "attributes": {} 328 | }, 329 | { 330 | "id": "f1afdbd2-ef03-4ebb-9f90-9bf2a2779c61", 331 | "name": "view-consent", 332 | "description": "${role_view-consent}", 333 | "composite": false, 334 | "clientRole": true, 335 | "containerId": "637d3007-a12d-49df-a028-f630822ccb03", 336 | "attributes": {} 337 | }, 338 | { 339 | "id": "b882441c-63e9-480d-a70e-2b8003dc0ef5", 340 | "name": "manage-account-links", 341 | "description": "${role_manage-account-links}", 342 | "composite": false, 343 | "clientRole": true, 344 | "containerId": "637d3007-a12d-49df-a028-f630822ccb03", 345 | "attributes": {} 346 | }, 347 | { 348 | "id": "739b55ac-ea80-4365-b2ef-9ac496ba2f16", 349 | "name": "manage-consent", 350 | "description": "${role_manage-consent}", 351 | "composite": true, 352 | "composites": { 353 | "client": { 354 | "account": [ 355 | "view-consent" 356 | ] 357 | } 358 | }, 359 | "clientRole": true, 360 | "containerId": "637d3007-a12d-49df-a028-f630822ccb03", 361 | "attributes": {} 362 | } 363 | ] 364 | } 365 | }, 366 | "groups": [], 367 | "defaultRoles": [ 368 | "offline_access", 369 | "uma_authorization" 370 | ], 371 | "requiredCredentials": [ 372 | "password" 373 | ], 374 | "otpPolicyType": "totp", 375 | "otpPolicyAlgorithm": "HmacSHA1", 376 | "otpPolicyInitialCounter": 0, 377 | "otpPolicyDigits": 6, 378 | "otpPolicyLookAheadWindow": 1, 379 | "otpPolicyPeriod": 30, 380 | "otpSupportedApplications": [ 381 | "FreeOTP", 382 | "Google Authenticator" 383 | ], 384 | "webAuthnPolicyRpEntityName": "keycloak", 385 | "webAuthnPolicySignatureAlgorithms": [ 386 | "ES256" 387 | ], 388 | "webAuthnPolicyRpId": "", 389 | "webAuthnPolicyAttestationConveyancePreference": "not specified", 390 | "webAuthnPolicyAuthenticatorAttachment": "not specified", 391 | "webAuthnPolicyRequireResidentKey": "not specified", 392 | "webAuthnPolicyUserVerificationRequirement": "not specified", 393 | "webAuthnPolicyCreateTimeout": 0, 394 | "webAuthnPolicyAvoidSameAuthenticatorRegister": false, 395 | "webAuthnPolicyAcceptableAaguids": [], 396 | "webAuthnPolicyPasswordlessRpEntityName": "keycloak", 397 | "webAuthnPolicyPasswordlessSignatureAlgorithms": [ 398 | "ES256" 399 | ], 400 | "webAuthnPolicyPasswordlessRpId": "", 401 | "webAuthnPolicyPasswordlessAttestationConveyancePreference": "not specified", 402 | "webAuthnPolicyPasswordlessAuthenticatorAttachment": "not specified", 403 | "webAuthnPolicyPasswordlessRequireResidentKey": "not specified", 404 | "webAuthnPolicyPasswordlessUserVerificationRequirement": "not specified", 405 | "webAuthnPolicyPasswordlessCreateTimeout": 0, 406 | "webAuthnPolicyPasswordlessAvoidSameAuthenticatorRegister": false, 407 | "webAuthnPolicyPasswordlessAcceptableAaguids": [], 408 | "scopeMappings": [ 409 | { 410 | "clientScope": "offline_access", 411 | "roles": [ 412 | "offline_access" 413 | ] 414 | } 415 | ], 416 | "clientScopeMappings": { 417 | "account": [ 418 | { 419 | "client": "account-console", 420 | "roles": [ 421 | "manage-account" 422 | ] 423 | } 424 | ] 425 | }, 426 | "clients": [ 427 | { 428 | "id": "637d3007-a12d-49df-a028-f630822ccb03", 429 | "clientId": "account", 430 | "name": "${client_account}", 431 | "rootUrl": "${authBaseUrl}", 432 | "baseUrl": "/realms/spring-micro-main/account/", 433 | "surrogateAuthRequired": false, 434 | "enabled": true, 435 | "alwaysDisplayInConsole": false, 436 | "clientAuthenticatorType": "client-secret", 437 | "secret": "**********", 438 | "defaultRoles": [ 439 | "view-profile", 440 | "manage-account" 441 | ], 442 | "redirectUris": [ 443 | "/realms/spring-micro-main/account/*" 444 | ], 445 | "webOrigins": [], 446 | "notBefore": 0, 447 | "bearerOnly": false, 448 | "consentRequired": false, 449 | "standardFlowEnabled": true, 450 | "implicitFlowEnabled": false, 451 | "directAccessGrantsEnabled": false, 452 | "serviceAccountsEnabled": false, 453 | "publicClient": false, 454 | "frontchannelLogout": false, 455 | "protocol": "openid-connect", 456 | "attributes": {}, 457 | "authenticationFlowBindingOverrides": {}, 458 | "fullScopeAllowed": false, 459 | "nodeReRegistrationTimeout": 0, 460 | "defaultClientScopes": [ 461 | "web-origins", 462 | "role_list", 463 | "roles", 464 | "profile", 465 | "email" 466 | ], 467 | "optionalClientScopes": [ 468 | "address", 469 | "phone", 470 | "offline_access", 471 | "microprofile-jwt" 472 | ] 473 | }, 474 | { 475 | "id": "a80e6b29-f927-45a0-a762-c7efb80aa6aa", 476 | "clientId": "account-console", 477 | "name": "${client_account-console}", 478 | "rootUrl": "${authBaseUrl}", 479 | "baseUrl": "/realms/spring-micro-main/account/", 480 | "surrogateAuthRequired": false, 481 | "enabled": true, 482 | "alwaysDisplayInConsole": false, 483 | "clientAuthenticatorType": "client-secret", 484 | "secret": "**********", 485 | "redirectUris": [ 486 | "/realms/spring-micro-main/account/*" 487 | ], 488 | "webOrigins": [], 489 | "notBefore": 0, 490 | "bearerOnly": false, 491 | "consentRequired": false, 492 | "standardFlowEnabled": true, 493 | "implicitFlowEnabled": false, 494 | "directAccessGrantsEnabled": false, 495 | "serviceAccountsEnabled": false, 496 | "publicClient": true, 497 | "frontchannelLogout": false, 498 | "protocol": "openid-connect", 499 | "attributes": { 500 | "pkce.code.challenge.method": "S256" 501 | }, 502 | "authenticationFlowBindingOverrides": {}, 503 | "fullScopeAllowed": false, 504 | "nodeReRegistrationTimeout": 0, 505 | "protocolMappers": [ 506 | { 507 | "id": "1971eaac-cbc6-46e1-b8ba-96e818c0022a", 508 | "name": "audience resolve", 509 | "protocol": "openid-connect", 510 | "protocolMapper": "oidc-audience-resolve-mapper", 511 | "consentRequired": false, 512 | "config": {} 513 | } 514 | ], 515 | "defaultClientScopes": [ 516 | "web-origins", 517 | "role_list", 518 | "roles", 519 | "profile", 520 | "email" 521 | ], 522 | "optionalClientScopes": [ 523 | "address", 524 | "phone", 525 | "offline_access", 526 | "microprofile-jwt" 527 | ] 528 | }, 529 | { 530 | "id": "a54f2497-39e0-42b0-9298-6d436f31e753", 531 | "clientId": "admin-cli", 532 | "name": "${client_admin-cli}", 533 | "surrogateAuthRequired": false, 534 | "enabled": true, 535 | "alwaysDisplayInConsole": false, 536 | "clientAuthenticatorType": "client-secret", 537 | "secret": "**********", 538 | "redirectUris": [], 539 | "webOrigins": [], 540 | "notBefore": 0, 541 | "bearerOnly": false, 542 | "consentRequired": false, 543 | "standardFlowEnabled": false, 544 | "implicitFlowEnabled": false, 545 | "directAccessGrantsEnabled": true, 546 | "serviceAccountsEnabled": false, 547 | "publicClient": true, 548 | "frontchannelLogout": false, 549 | "protocol": "openid-connect", 550 | "attributes": {}, 551 | "authenticationFlowBindingOverrides": {}, 552 | "fullScopeAllowed": false, 553 | "nodeReRegistrationTimeout": 0, 554 | "defaultClientScopes": [ 555 | "web-origins", 556 | "role_list", 557 | "roles", 558 | "profile", 559 | "email" 560 | ], 561 | "optionalClientScopes": [ 562 | "address", 563 | "phone", 564 | "offline_access", 565 | "microprofile-jwt" 566 | ] 567 | }, 568 | { 569 | "id": "ac7ca518-46d5-49d2-ba3b-931034c725f8", 570 | "clientId": "broker", 571 | "name": "${client_broker}", 572 | "surrogateAuthRequired": false, 573 | "enabled": true, 574 | "alwaysDisplayInConsole": false, 575 | "clientAuthenticatorType": "client-secret", 576 | "secret": "**********", 577 | "redirectUris": [], 578 | "webOrigins": [], 579 | "notBefore": 0, 580 | "bearerOnly": false, 581 | "consentRequired": false, 582 | "standardFlowEnabled": true, 583 | "implicitFlowEnabled": false, 584 | "directAccessGrantsEnabled": false, 585 | "serviceAccountsEnabled": false, 586 | "publicClient": false, 587 | "frontchannelLogout": false, 588 | "protocol": "openid-connect", 589 | "attributes": {}, 590 | "authenticationFlowBindingOverrides": {}, 591 | "fullScopeAllowed": false, 592 | "nodeReRegistrationTimeout": 0, 593 | "defaultClientScopes": [ 594 | "web-origins", 595 | "role_list", 596 | "roles", 597 | "profile", 598 | "email" 599 | ], 600 | "optionalClientScopes": [ 601 | "address", 602 | "phone", 603 | "offline_access", 604 | "microprofile-jwt" 605 | ] 606 | }, 607 | { 608 | "id": "5cc089bb-0b35-4818-a951-617beede0e65", 609 | "clientId": "realm-management", 610 | "name": "${client_realm-management}", 611 | "surrogateAuthRequired": false, 612 | "enabled": true, 613 | "alwaysDisplayInConsole": false, 614 | "clientAuthenticatorType": "client-secret", 615 | "secret": "**********", 616 | "redirectUris": [], 617 | "webOrigins": [], 618 | "notBefore": 0, 619 | "bearerOnly": true, 620 | "consentRequired": false, 621 | "standardFlowEnabled": true, 622 | "implicitFlowEnabled": false, 623 | "directAccessGrantsEnabled": false, 624 | "serviceAccountsEnabled": false, 625 | "publicClient": false, 626 | "frontchannelLogout": false, 627 | "protocol": "openid-connect", 628 | "attributes": {}, 629 | "authenticationFlowBindingOverrides": {}, 630 | "fullScopeAllowed": false, 631 | "nodeReRegistrationTimeout": 0, 632 | "defaultClientScopes": [ 633 | "web-origins", 634 | "role_list", 635 | "roles", 636 | "profile", 637 | "email" 638 | ], 639 | "optionalClientScopes": [ 640 | "address", 641 | "phone", 642 | "offline_access", 643 | "microprofile-jwt" 644 | ] 645 | }, 646 | { 647 | "id": "b79d2aa1-9f5b-41f4-8e32-c0e837804a1f", 648 | "clientId": "security-admin-console", 649 | "name": "${client_security-admin-console}", 650 | "rootUrl": "${authAdminUrl}", 651 | "baseUrl": "/admin/spring-micro-main/console/", 652 | "surrogateAuthRequired": false, 653 | "enabled": true, 654 | "alwaysDisplayInConsole": false, 655 | "clientAuthenticatorType": "client-secret", 656 | "secret": "**********", 657 | "redirectUris": [ 658 | "/admin/spring-micro-main/console/*" 659 | ], 660 | "webOrigins": [ 661 | "+" 662 | ], 663 | "notBefore": 0, 664 | "bearerOnly": false, 665 | "consentRequired": false, 666 | "standardFlowEnabled": true, 667 | "implicitFlowEnabled": false, 668 | "directAccessGrantsEnabled": false, 669 | "serviceAccountsEnabled": false, 670 | "publicClient": true, 671 | "frontchannelLogout": false, 672 | "protocol": "openid-connect", 673 | "attributes": { 674 | "pkce.code.challenge.method": "S256" 675 | }, 676 | "authenticationFlowBindingOverrides": {}, 677 | "fullScopeAllowed": false, 678 | "nodeReRegistrationTimeout": 0, 679 | "protocolMappers": [ 680 | { 681 | "id": "ac407bd2-258d-4923-b1b0-bc6798fc6327", 682 | "name": "locale", 683 | "protocol": "openid-connect", 684 | "protocolMapper": "oidc-usermodel-attribute-mapper", 685 | "consentRequired": false, 686 | "config": { 687 | "userinfo.token.claim": "true", 688 | "user.attribute": "locale", 689 | "id.token.claim": "true", 690 | "access.token.claim": "true", 691 | "claim.name": "locale", 692 | "jsonType.label": "String" 693 | } 694 | } 695 | ], 696 | "defaultClientScopes": [ 697 | "web-origins", 698 | "role_list", 699 | "roles", 700 | "profile", 701 | "email" 702 | ], 703 | "optionalClientScopes": [ 704 | "address", 705 | "phone", 706 | "offline_access", 707 | "microprofile-jwt" 708 | ] 709 | }, 710 | { 711 | "id": "125b17ed-c1dc-4b2c-b325-828e2072dbe7", 712 | "clientId": "spring-micro-consumer", 713 | "surrogateAuthRequired": false, 714 | "enabled": true, 715 | "alwaysDisplayInConsole": false, 716 | "clientAuthenticatorType": "client-secret", 717 | "secret": "**********", 718 | "redirectUris": [ 719 | "*" 720 | ], 721 | "webOrigins": [], 722 | "notBefore": 0, 723 | "bearerOnly": false, 724 | "consentRequired": false, 725 | "standardFlowEnabled": true, 726 | "implicitFlowEnabled": false, 727 | "directAccessGrantsEnabled": true, 728 | "serviceAccountsEnabled": false, 729 | "publicClient": false, 730 | "frontchannelLogout": false, 731 | "protocol": "openid-connect", 732 | "attributes": { 733 | "saml.assertion.signature": "false", 734 | "saml.force.post.binding": "false", 735 | "saml.multivalued.roles": "false", 736 | "saml.encrypt": "false", 737 | "saml.server.signature": "false", 738 | "saml.server.signature.keyinfo.ext": "false", 739 | "exclude.session.state.from.auth.response": "false", 740 | "jwt.credential.certificate": "MIICuTCCAaECBgF1CkS+YjANBgkqhkiG9w0BAQsFADAgMR4wHAYDVQQDDBVzcHJpbmctbWljcm8tY29uc3VtZXIwHhcNMjAxMDA4MjIwOTM4WhcNMzAxMDA4MjIxMTE4WjAgMR4wHAYDVQQDDBVzcHJpbmctbWljcm8tY29uc3VtZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCDGyWCm8EvXY6qpu6jHA6BIUn9N8auOuV4YFR+dEkTToOEx4HdPPlPku9tHyNNnZEIZuoQmfdNDcW4w2msM02If8C1VI92yZryRcJsLpIbXorOaIbmYRwm4PYb4YWVP480nqWhSL0H3VozbLX6ligKLvwsSXaJK0LmTJ3lbLJV1Z3jxMbZEdOZhj2zjamAaBVtLWyC7/80jZuQU1PuPrg77A9oUxSAJSqqGexRvedNIuTc7YMcaDl4EdOVAQqUdiFEozfoEP7boLaoT4i5XaYVFmNyUwQeR3WIQ1Ee+hxzoW6ggkFz4QC+7T8yuuBZgdfrmAsFGHfpJG768wd8gVhVAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAGCaNmCR6p4hQaEZgAJtnXNBrdx5Ryj90+jAt9QVqvEGmGdV1Y8GQ5iUJ1ko4t1rlc/XtbpmKsGc6rCd2IeR1LmGVvP7wChMCKWXUjI/SN9dQxCcXqPddv1SYxNKwKCBtZj2Ha/c2okJK+zUF7hEr4Sv91GX5Lh2pWIeHXwm6ln9wVHVGNy5ar3hrirRj4hquipDca6H2OcuFFpakRDUo67L2QL+F8jeU+EDCSn3xcRd3FcIWNRIFaNtD02CUAna3/BFD+O6viPE/dt3kA0cvtZ2EX+z4Yx2WGfm0PQSkDB83fY1GuXZglRt5ZEvtEcVKyl//vwIZd9eQAEzjDHRBUg=", 741 | "saml_force_name_id_format": "false", 742 | "saml.client.signature": "false", 743 | "tls.client.certificate.bound.access.tokens": "false", 744 | "saml.authnstatement": "false", 745 | "display.on.consent.screen": "false", 746 | "saml.onetimeuse.condition": "false" 747 | }, 748 | "authenticationFlowBindingOverrides": {}, 749 | "fullScopeAllowed": true, 750 | "nodeReRegistrationTimeout": -1, 751 | "defaultClientScopes": [ 752 | "web-origins", 753 | "role_list", 754 | "roles", 755 | "profile", 756 | "email" 757 | ], 758 | "optionalClientScopes": [ 759 | "address", 760 | "phone", 761 | "offline_access", 762 | "microprofile-jwt" 763 | ] 764 | }, 765 | { 766 | "id": "bef7f291-3e40-4ef4-bed3-849274253c99", 767 | "clientId": "spring-micro-gateway", 768 | "surrogateAuthRequired": false, 769 | "enabled": true, 770 | "alwaysDisplayInConsole": false, 771 | "clientAuthenticatorType": "client-secret", 772 | "secret": "**********", 773 | "redirectUris": [ 774 | "*" 775 | ], 776 | "webOrigins": [], 777 | "notBefore": 0, 778 | "bearerOnly": false, 779 | "consentRequired": false, 780 | "standardFlowEnabled": true, 781 | "implicitFlowEnabled": false, 782 | "directAccessGrantsEnabled": true, 783 | "serviceAccountsEnabled": false, 784 | "publicClient": false, 785 | "frontchannelLogout": false, 786 | "protocol": "openid-connect", 787 | "attributes": { 788 | "saml.assertion.signature": "false", 789 | "saml.force.post.binding": "false", 790 | "saml.multivalued.roles": "false", 791 | "saml.encrypt": "false", 792 | "use.jwks.url": "false", 793 | "saml.server.signature": "false", 794 | "saml.server.signature.keyinfo.ext": "false", 795 | "exclude.session.state.from.auth.response": "false", 796 | "jwt.credential.certificate": "MIICtzCCAZ8CBgF1CjBbQjANBgkqhkiG9w0BAQsFADAfMR0wGwYDVQQDDBRzcHJpbmctbWljcm8tZ2F0ZXdheTAeFw0yMDEwMDgyMTQ3MjJaFw0zMDEwMDgyMTQ5MDJaMB8xHTAbBgNVBAMMFHNwcmluZy1taWNyby1nYXRld2F5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz9TEnlFw8VFeaVhKZsgbwUIo8DCt82KzRg7mxRpeOqA55oDgJAafD50WR+1fiVHo2UNZnTwmR8kdINQZQv7NcRrGT0C4i3+8aSRCIlliTdSHjHZdyJZEzy9SxTrbPkp96lD1unvlFQrDMDlv3hn45lupqo8QkaAN0wM1Wvg5En+P//w3jVP/pKqTK9l+fxlRVC/YmB+z9jlLX7TgL7/RS+qR7eMQ5QBl/udrT6VDKV0oUeCdef2UXE+0CY96/IKjpjrGmDk5gEpb2rWPKUrNu/6X8yCPX4nC1Yj5r6ZhW8eQh6/oR38fT8NJ8ZhaqrVKdOALW6nu3agKwPNtD6i3uwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBnWNuH8i54g+dsd5rzy1KRaNd5e1DJaIIPj9h4HB6BXTMr130juh0Vo5YLJWjDcxhg5Wy+nEvLuGll6qXMqPE86EbGhBFQLlcayIfLjCdVptcMNzFTIrDpOLmmZsVCwU0dUFCs0UvMLIv7iWppkaB77h4Qplptv4sLQr8xspcZPdiFHEFombuVeblNC4qY/Xot++bAvTcXNNEzCKyuZIuWfV+IIlI/KK2tmf1oc8oGeZoj1LnZ5y82oYdDL/MUMIIxMPzcANVfOLS3Mkg1NHp69Sk0Rl3Ov3URl/SWW7mkgr4gDDlbcs6aG8ZS/z+Nt5m96bG23yZLnNIjkASm7bIq", 797 | "jwks.url": "/oauth/token_key", 798 | "saml_force_name_id_format": "false", 799 | "saml.client.signature": "false", 800 | "tls.client.certificate.bound.access.tokens": "false", 801 | "saml.authnstatement": "false", 802 | "display.on.consent.screen": "false", 803 | "saml.onetimeuse.condition": "false" 804 | }, 805 | "authenticationFlowBindingOverrides": {}, 806 | "fullScopeAllowed": true, 807 | "nodeReRegistrationTimeout": -1, 808 | "defaultClientScopes": [ 809 | "web-origins", 810 | "role_list", 811 | "roles", 812 | "profile", 813 | "email" 814 | ], 815 | "optionalClientScopes": [ 816 | "address", 817 | "phone", 818 | "offline_access", 819 | "microprofile-jwt" 820 | ] 821 | }, 822 | { 823 | "id": "8df4e86d-a91b-4310-b6f7-abefb34b55b7", 824 | "clientId": "spring-micro-producer", 825 | "surrogateAuthRequired": false, 826 | "enabled": true, 827 | "alwaysDisplayInConsole": false, 828 | "clientAuthenticatorType": "client-secret", 829 | "secret": "**********", 830 | "redirectUris": [ 831 | "*" 832 | ], 833 | "webOrigins": [], 834 | "notBefore": 0, 835 | "bearerOnly": false, 836 | "consentRequired": false, 837 | "standardFlowEnabled": true, 838 | "implicitFlowEnabled": false, 839 | "directAccessGrantsEnabled": true, 840 | "serviceAccountsEnabled": false, 841 | "publicClient": false, 842 | "frontchannelLogout": false, 843 | "protocol": "openid-connect", 844 | "attributes": { 845 | "saml.assertion.signature": "false", 846 | "saml.force.post.binding": "false", 847 | "saml.multivalued.roles": "false", 848 | "saml.encrypt": "false", 849 | "saml.server.signature": "false", 850 | "saml.server.signature.keyinfo.ext": "false", 851 | "exclude.session.state.from.auth.response": "false", 852 | "jwt.credential.certificate": "MIICuTCCAaECBgF1CkOtRDANBgkqhkiG9w0BAQsFADAgMR4wHAYDVQQDDBVzcHJpbmctbWljcm8tcHJvZHVjZXIwHhcNMjAxMDA4MjIwODI4WhcNMzAxMDA4MjIxMDA4WjAgMR4wHAYDVQQDDBVzcHJpbmctbWljcm8tcHJvZHVjZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCn0V0eIdRkfXVOxBEztgp3A6xbAnMTC9SEnAZL9nuGyh6oIBXmsplvd4lSIxxEJL0tHMdCi4PgIAXigGMZqxXBFiS0sC8q1ypQby0rPBhSiHQA5Lun6tr9x6lZ5yO38BlSwklcE7mC1604t6p4zJB5aK3P5qXYdMtkQxoql5bbMsjBGxFO1v/IjTb2QXwqiamxIEneLFv7RXqsIKfEQMqhjgLd2qzE+FgTHBGPdB15beIIG84grzlRUhkNXL+Rz7XQmj7QaqHau44MXlMPplue6BR5+4jxmkkObgbrZztLLZsNcWYUBESNcd22JLwTJtvb1cXXfIhLZuU11L4NYy55AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAJ1hAd8Lsav8gcBBpYlnX+IHjEogMJVwP6q/NP1YUrfOi7l++pDaxj8pVAEjmYeP5ESXP0cafZHngSHIl9VfDy/4otUv2/Po405ChU4AGffkV7SPUSKoazZoqhCtGuKBMtJkB0sBpqQjvB6dO0uE9jXMM1LcsNe3fGrbiYY38aRlVV3plibNBjE3ZwgXfxQhS/1i4BDU1WhpkJQcH8Pi7ooF7f39gAiCU/Evm4TV4QkmKL6GKQ50mJe5sPXbvMlEkUmR65F39Wb1Bslb9+tg9dbjUtdnVQBt7wm3mZw3f3KlZpY+zhw4pvBwrk28BS3WvuBe6UCcy0wKafkLUbxZvL4=", 853 | "saml_force_name_id_format": "false", 854 | "saml.client.signature": "false", 855 | "tls.client.certificate.bound.access.tokens": "false", 856 | "saml.authnstatement": "false", 857 | "display.on.consent.screen": "false", 858 | "saml.onetimeuse.condition": "false" 859 | }, 860 | "authenticationFlowBindingOverrides": {}, 861 | "fullScopeAllowed": true, 862 | "nodeReRegistrationTimeout": -1, 863 | "defaultClientScopes": [ 864 | "web-origins", 865 | "role_list", 866 | "roles", 867 | "profile", 868 | "email" 869 | ], 870 | "optionalClientScopes": [ 871 | "address", 872 | "phone", 873 | "offline_access", 874 | "microprofile-jwt" 875 | ] 876 | } 877 | ], 878 | "clientScopes": [ 879 | { 880 | "id": "d6cfa85e-7527-4f55-bfad-7c21515fc2d7", 881 | "name": "offline_access", 882 | "description": "OpenID Connect built-in scope: offline_access", 883 | "protocol": "openid-connect", 884 | "attributes": { 885 | "consent.screen.text": "${offlineAccessScopeConsentText}", 886 | "display.on.consent.screen": "true" 887 | } 888 | }, 889 | { 890 | "id": "9ce62885-e1b3-469b-9414-2fcfdf478fb7", 891 | "name": "role_list", 892 | "description": "SAML role list", 893 | "protocol": "saml", 894 | "attributes": { 895 | "consent.screen.text": "${samlRoleListScopeConsentText}", 896 | "display.on.consent.screen": "true" 897 | }, 898 | "protocolMappers": [ 899 | { 900 | "id": "759afb0e-e0a1-47e0-be49-350ef8f6fde3", 901 | "name": "role list", 902 | "protocol": "saml", 903 | "protocolMapper": "saml-role-list-mapper", 904 | "consentRequired": false, 905 | "config": { 906 | "single": "false", 907 | "attribute.nameformat": "Basic", 908 | "attribute.name": "Role" 909 | } 910 | } 911 | ] 912 | }, 913 | { 914 | "id": "29106668-f2bc-4356-8927-84b6983ef635", 915 | "name": "profile", 916 | "description": "OpenID Connect built-in scope: profile", 917 | "protocol": "openid-connect", 918 | "attributes": { 919 | "include.in.token.scope": "true", 920 | "display.on.consent.screen": "true", 921 | "consent.screen.text": "${profileScopeConsentText}" 922 | }, 923 | "protocolMappers": [ 924 | { 925 | "id": "471d2448-5408-416a-affb-be123871331c", 926 | "name": "family name", 927 | "protocol": "openid-connect", 928 | "protocolMapper": "oidc-usermodel-property-mapper", 929 | "consentRequired": false, 930 | "config": { 931 | "userinfo.token.claim": "true", 932 | "user.attribute": "lastName", 933 | "id.token.claim": "true", 934 | "access.token.claim": "true", 935 | "claim.name": "family_name", 936 | "jsonType.label": "String" 937 | } 938 | }, 939 | { 940 | "id": "8bdfe2a2-aaf6-42eb-810d-5775e684c963", 941 | "name": "zoneinfo", 942 | "protocol": "openid-connect", 943 | "protocolMapper": "oidc-usermodel-attribute-mapper", 944 | "consentRequired": false, 945 | "config": { 946 | "userinfo.token.claim": "true", 947 | "user.attribute": "zoneinfo", 948 | "id.token.claim": "true", 949 | "access.token.claim": "true", 950 | "claim.name": "zoneinfo", 951 | "jsonType.label": "String" 952 | } 953 | }, 954 | { 955 | "id": "abf84c63-a0c9-4069-9dee-805b39b7c647", 956 | "name": "profile", 957 | "protocol": "openid-connect", 958 | "protocolMapper": "oidc-usermodel-attribute-mapper", 959 | "consentRequired": false, 960 | "config": { 961 | "userinfo.token.claim": "true", 962 | "user.attribute": "profile", 963 | "id.token.claim": "true", 964 | "access.token.claim": "true", 965 | "claim.name": "profile", 966 | "jsonType.label": "String" 967 | } 968 | }, 969 | { 970 | "id": "24f9b625-61cc-4fa7-9a36-faff76c7ea55", 971 | "name": "username", 972 | "protocol": "openid-connect", 973 | "protocolMapper": "oidc-usermodel-property-mapper", 974 | "consentRequired": false, 975 | "config": { 976 | "userinfo.token.claim": "true", 977 | "user.attribute": "username", 978 | "id.token.claim": "true", 979 | "access.token.claim": "true", 980 | "claim.name": "preferred_username", 981 | "jsonType.label": "String" 982 | } 983 | }, 984 | { 985 | "id": "50354e0b-aad9-4917-9081-7f5e43681dcd", 986 | "name": "given name", 987 | "protocol": "openid-connect", 988 | "protocolMapper": "oidc-usermodel-property-mapper", 989 | "consentRequired": false, 990 | "config": { 991 | "userinfo.token.claim": "true", 992 | "user.attribute": "firstName", 993 | "id.token.claim": "true", 994 | "access.token.claim": "true", 995 | "claim.name": "given_name", 996 | "jsonType.label": "String" 997 | } 998 | }, 999 | { 1000 | "id": "4e3e521b-f430-40e2-aed0-2593fed1e5f2", 1001 | "name": "updated at", 1002 | "protocol": "openid-connect", 1003 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1004 | "consentRequired": false, 1005 | "config": { 1006 | "userinfo.token.claim": "true", 1007 | "user.attribute": "updatedAt", 1008 | "id.token.claim": "true", 1009 | "access.token.claim": "true", 1010 | "claim.name": "updated_at", 1011 | "jsonType.label": "String" 1012 | } 1013 | }, 1014 | { 1015 | "id": "6a45970b-0a1a-4aaa-9662-f6aa3d100afc", 1016 | "name": "website", 1017 | "protocol": "openid-connect", 1018 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1019 | "consentRequired": false, 1020 | "config": { 1021 | "userinfo.token.claim": "true", 1022 | "user.attribute": "website", 1023 | "id.token.claim": "true", 1024 | "access.token.claim": "true", 1025 | "claim.name": "website", 1026 | "jsonType.label": "String" 1027 | } 1028 | }, 1029 | { 1030 | "id": "9b84960f-4053-4c0b-9e3f-97e9baafcf96", 1031 | "name": "gender", 1032 | "protocol": "openid-connect", 1033 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1034 | "consentRequired": false, 1035 | "config": { 1036 | "userinfo.token.claim": "true", 1037 | "user.attribute": "gender", 1038 | "id.token.claim": "true", 1039 | "access.token.claim": "true", 1040 | "claim.name": "gender", 1041 | "jsonType.label": "String" 1042 | } 1043 | }, 1044 | { 1045 | "id": "48c945ad-b0b8-402d-b1c6-4b775cb6310d", 1046 | "name": "nickname", 1047 | "protocol": "openid-connect", 1048 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1049 | "consentRequired": false, 1050 | "config": { 1051 | "userinfo.token.claim": "true", 1052 | "user.attribute": "nickname", 1053 | "id.token.claim": "true", 1054 | "access.token.claim": "true", 1055 | "claim.name": "nickname", 1056 | "jsonType.label": "String" 1057 | } 1058 | }, 1059 | { 1060 | "id": "339c8dd7-0b1b-4c28-a5ee-a2efe72c0248", 1061 | "name": "full name", 1062 | "protocol": "openid-connect", 1063 | "protocolMapper": "oidc-full-name-mapper", 1064 | "consentRequired": false, 1065 | "config": { 1066 | "id.token.claim": "true", 1067 | "access.token.claim": "true", 1068 | "userinfo.token.claim": "true" 1069 | } 1070 | }, 1071 | { 1072 | "id": "2936cdb5-c40f-4f32-a933-107623ba9403", 1073 | "name": "locale", 1074 | "protocol": "openid-connect", 1075 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1076 | "consentRequired": false, 1077 | "config": { 1078 | "userinfo.token.claim": "true", 1079 | "user.attribute": "locale", 1080 | "id.token.claim": "true", 1081 | "access.token.claim": "true", 1082 | "claim.name": "locale", 1083 | "jsonType.label": "String" 1084 | } 1085 | }, 1086 | { 1087 | "id": "5ee8ff91-21c2-40d9-913d-ce822351de66", 1088 | "name": "picture", 1089 | "protocol": "openid-connect", 1090 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1091 | "consentRequired": false, 1092 | "config": { 1093 | "userinfo.token.claim": "true", 1094 | "user.attribute": "picture", 1095 | "id.token.claim": "true", 1096 | "access.token.claim": "true", 1097 | "claim.name": "picture", 1098 | "jsonType.label": "String" 1099 | } 1100 | }, 1101 | { 1102 | "id": "30f98839-5d5e-4000-828d-e144b2166f4b", 1103 | "name": "birthdate", 1104 | "protocol": "openid-connect", 1105 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1106 | "consentRequired": false, 1107 | "config": { 1108 | "userinfo.token.claim": "true", 1109 | "user.attribute": "birthdate", 1110 | "id.token.claim": "true", 1111 | "access.token.claim": "true", 1112 | "claim.name": "birthdate", 1113 | "jsonType.label": "String" 1114 | } 1115 | }, 1116 | { 1117 | "id": "df93e4c8-d716-48ba-8c2d-eee65bf3a8a9", 1118 | "name": "middle name", 1119 | "protocol": "openid-connect", 1120 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1121 | "consentRequired": false, 1122 | "config": { 1123 | "userinfo.token.claim": "true", 1124 | "user.attribute": "middleName", 1125 | "id.token.claim": "true", 1126 | "access.token.claim": "true", 1127 | "claim.name": "middle_name", 1128 | "jsonType.label": "String" 1129 | } 1130 | } 1131 | ] 1132 | }, 1133 | { 1134 | "id": "58e738fa-38da-4a92-a185-f3bbbe1393c2", 1135 | "name": "email", 1136 | "description": "OpenID Connect built-in scope: email", 1137 | "protocol": "openid-connect", 1138 | "attributes": { 1139 | "include.in.token.scope": "true", 1140 | "display.on.consent.screen": "true", 1141 | "consent.screen.text": "${emailScopeConsentText}" 1142 | }, 1143 | "protocolMappers": [ 1144 | { 1145 | "id": "0862846d-828c-450a-ae73-e7bc38cc1f20", 1146 | "name": "email", 1147 | "protocol": "openid-connect", 1148 | "protocolMapper": "oidc-usermodel-property-mapper", 1149 | "consentRequired": false, 1150 | "config": { 1151 | "userinfo.token.claim": "true", 1152 | "user.attribute": "email", 1153 | "id.token.claim": "true", 1154 | "access.token.claim": "true", 1155 | "claim.name": "email", 1156 | "jsonType.label": "String" 1157 | } 1158 | }, 1159 | { 1160 | "id": "f9010082-f972-4786-9742-d6773be4cd87", 1161 | "name": "email verified", 1162 | "protocol": "openid-connect", 1163 | "protocolMapper": "oidc-usermodel-property-mapper", 1164 | "consentRequired": false, 1165 | "config": { 1166 | "userinfo.token.claim": "true", 1167 | "user.attribute": "emailVerified", 1168 | "id.token.claim": "true", 1169 | "access.token.claim": "true", 1170 | "claim.name": "email_verified", 1171 | "jsonType.label": "boolean" 1172 | } 1173 | } 1174 | ] 1175 | }, 1176 | { 1177 | "id": "aa02e35e-1c0e-47ad-a5f7-869f408004d2", 1178 | "name": "address", 1179 | "description": "OpenID Connect built-in scope: address", 1180 | "protocol": "openid-connect", 1181 | "attributes": { 1182 | "include.in.token.scope": "true", 1183 | "display.on.consent.screen": "true", 1184 | "consent.screen.text": "${addressScopeConsentText}" 1185 | }, 1186 | "protocolMappers": [ 1187 | { 1188 | "id": "459e962f-37d4-4428-a701-a2d91c6e148b", 1189 | "name": "address", 1190 | "protocol": "openid-connect", 1191 | "protocolMapper": "oidc-address-mapper", 1192 | "consentRequired": false, 1193 | "config": { 1194 | "user.attribute.formatted": "formatted", 1195 | "user.attribute.country": "country", 1196 | "user.attribute.postal_code": "postal_code", 1197 | "userinfo.token.claim": "true", 1198 | "user.attribute.street": "street", 1199 | "id.token.claim": "true", 1200 | "user.attribute.region": "region", 1201 | "access.token.claim": "true", 1202 | "user.attribute.locality": "locality" 1203 | } 1204 | } 1205 | ] 1206 | }, 1207 | { 1208 | "id": "4977814d-357b-43d8-a752-af5431951da7", 1209 | "name": "phone", 1210 | "description": "OpenID Connect built-in scope: phone", 1211 | "protocol": "openid-connect", 1212 | "attributes": { 1213 | "include.in.token.scope": "true", 1214 | "display.on.consent.screen": "true", 1215 | "consent.screen.text": "${phoneScopeConsentText}" 1216 | }, 1217 | "protocolMappers": [ 1218 | { 1219 | "id": "4ef0080d-09f8-4148-9bf6-d3a500522962", 1220 | "name": "phone number", 1221 | "protocol": "openid-connect", 1222 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1223 | "consentRequired": false, 1224 | "config": { 1225 | "userinfo.token.claim": "true", 1226 | "user.attribute": "phoneNumber", 1227 | "id.token.claim": "true", 1228 | "access.token.claim": "true", 1229 | "claim.name": "phone_number", 1230 | "jsonType.label": "String" 1231 | } 1232 | }, 1233 | { 1234 | "id": "cd9815fa-88ec-4c08-95ad-5bf5792cc185", 1235 | "name": "phone number verified", 1236 | "protocol": "openid-connect", 1237 | "protocolMapper": "oidc-usermodel-attribute-mapper", 1238 | "consentRequired": false, 1239 | "config": { 1240 | "userinfo.token.claim": "true", 1241 | "user.attribute": "phoneNumberVerified", 1242 | "id.token.claim": "true", 1243 | "access.token.claim": "true", 1244 | "claim.name": "phone_number_verified", 1245 | "jsonType.label": "boolean" 1246 | } 1247 | } 1248 | ] 1249 | }, 1250 | { 1251 | "id": "cf53b278-8a27-42fe-97e0-ad1277e52a2b", 1252 | "name": "roles", 1253 | "description": "OpenID Connect scope for add user roles to the access token", 1254 | "protocol": "openid-connect", 1255 | "attributes": { 1256 | "include.in.token.scope": "false", 1257 | "display.on.consent.screen": "true", 1258 | "consent.screen.text": "${rolesScopeConsentText}" 1259 | }, 1260 | "protocolMappers": [ 1261 | { 1262 | "id": "611a2533-492f-4ffa-b11c-9749d8e46dde", 1263 | "name": "audience resolve", 1264 | "protocol": "openid-connect", 1265 | "protocolMapper": "oidc-audience-resolve-mapper", 1266 | "consentRequired": false, 1267 | "config": {} 1268 | }, 1269 | { 1270 | "id": "74ca2879-e8cb-4bf6-9237-b78ef5d5ecd9", 1271 | "name": "realm roles", 1272 | "protocol": "openid-connect", 1273 | "protocolMapper": "oidc-usermodel-realm-role-mapper", 1274 | "consentRequired": false, 1275 | "config": { 1276 | "user.attribute": "foo", 1277 | "access.token.claim": "true", 1278 | "claim.name": "realm_access.roles", 1279 | "jsonType.label": "String", 1280 | "multivalued": "true" 1281 | } 1282 | }, 1283 | { 1284 | "id": "0806a2b1-7aad-4553-b496-869eeec233d9", 1285 | "name": "client roles", 1286 | "protocol": "openid-connect", 1287 | "protocolMapper": "oidc-usermodel-client-role-mapper", 1288 | "consentRequired": false, 1289 | "config": { 1290 | "user.attribute": "foo", 1291 | "access.token.claim": "true", 1292 | "claim.name": "resource_access.${client_id}.roles", 1293 | "jsonType.label": "String", 1294 | "multivalued": "true" 1295 | } 1296 | } 1297 | ] 1298 | }, 1299 | { 1300 | "id": "e70958e5-2743-4cc2-81be-0b361945b19f", 1301 | "name": "web-origins", 1302 | "description": "OpenID Connect scope for add allowed web origins to the access token", 1303 | "protocol": "openid-connect", 1304 | "attributes": { 1305 | "include.in.token.scope": "false", 1306 | "display.on.consent.screen": "false", 1307 | "consent.screen.text": "" 1308 | }, 1309 | "protocolMappers": [ 1310 | { 1311 | "id": "8d736b60-3496-4ccf-9cd5-8eb535626c8a", 1312 | "name": "allowed web origins", 1313 | "protocol": "openid-connect", 1314 | "protocolMapper": "oidc-allowed-origins-mapper", 1315 | "consentRequired": false, 1316 | "config": {} 1317 | } 1318 | ] 1319 | }, 1320 | { 1321 | "id": "102a3aa0-9c8d-4a5d-8ebf-d938e49c8213", 1322 | "name": "microprofile-jwt", 1323 | "description": "Microprofile - JWT built-in scope", 1324 | "protocol": "openid-connect", 1325 | "attributes": { 1326 | "include.in.token.scope": "true", 1327 | "display.on.consent.screen": "false" 1328 | }, 1329 | "protocolMappers": [ 1330 | { 1331 | "id": "ff30e9a0-9a36-4baa-b93d-e4f2fadde68d", 1332 | "name": "upn", 1333 | "protocol": "openid-connect", 1334 | "protocolMapper": "oidc-usermodel-property-mapper", 1335 | "consentRequired": false, 1336 | "config": { 1337 | "userinfo.token.claim": "true", 1338 | "user.attribute": "username", 1339 | "id.token.claim": "true", 1340 | "access.token.claim": "true", 1341 | "claim.name": "upn", 1342 | "jsonType.label": "String" 1343 | } 1344 | }, 1345 | { 1346 | "id": "a68741f8-9939-42c1-8d1b-324f87600208", 1347 | "name": "groups", 1348 | "protocol": "openid-connect", 1349 | "protocolMapper": "oidc-usermodel-realm-role-mapper", 1350 | "consentRequired": false, 1351 | "config": { 1352 | "multivalued": "true", 1353 | "user.attribute": "foo", 1354 | "id.token.claim": "true", 1355 | "access.token.claim": "true", 1356 | "claim.name": "groups", 1357 | "jsonType.label": "String" 1358 | } 1359 | } 1360 | ] 1361 | } 1362 | ], 1363 | "defaultDefaultClientScopes": [ 1364 | "role_list", 1365 | "profile", 1366 | "email", 1367 | "roles", 1368 | "web-origins" 1369 | ], 1370 | "defaultOptionalClientScopes": [ 1371 | "offline_access", 1372 | "address", 1373 | "phone", 1374 | "microprofile-jwt" 1375 | ], 1376 | "browserSecurityHeaders": { 1377 | "contentSecurityPolicyReportOnly": "", 1378 | "xContentTypeOptions": "nosniff", 1379 | "xRobotsTag": "none", 1380 | "xFrameOptions": "SAMEORIGIN", 1381 | "contentSecurityPolicy": "frame-src 'self'; frame-ancestors 'self'; object-src 'none';", 1382 | "xXSSProtection": "1; mode=block", 1383 | "strictTransportSecurity": "max-age=31536000; includeSubDomains" 1384 | }, 1385 | "smtpServer": {}, 1386 | "eventsEnabled": false, 1387 | "eventsListeners": [ 1388 | "jboss-logging" 1389 | ], 1390 | "enabledEventTypes": [], 1391 | "adminEventsEnabled": false, 1392 | "adminEventsDetailsEnabled": false, 1393 | "components": { 1394 | "org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy": [ 1395 | { 1396 | "id": "f7166cc7-1dbb-4d25-8b12-cc1e129fefc2", 1397 | "name": "Max Clients Limit", 1398 | "providerId": "max-clients", 1399 | "subType": "anonymous", 1400 | "subComponents": {}, 1401 | "config": { 1402 | "max-clients": [ 1403 | "200" 1404 | ] 1405 | } 1406 | }, 1407 | { 1408 | "id": "12750a81-1129-4b44-b5b4-661f46cf2a04", 1409 | "name": "Allowed Client Scopes", 1410 | "providerId": "allowed-client-templates", 1411 | "subType": "anonymous", 1412 | "subComponents": {}, 1413 | "config": { 1414 | "allow-default-scopes": [ 1415 | "true" 1416 | ] 1417 | } 1418 | }, 1419 | { 1420 | "id": "0c1a9315-437d-47e2-8302-57e1f445f040", 1421 | "name": "Allowed Protocol Mapper Types", 1422 | "providerId": "allowed-protocol-mappers", 1423 | "subType": "anonymous", 1424 | "subComponents": {}, 1425 | "config": { 1426 | "allowed-protocol-mapper-types": [ 1427 | "saml-user-property-mapper", 1428 | "oidc-address-mapper", 1429 | "oidc-usermodel-attribute-mapper", 1430 | "oidc-full-name-mapper", 1431 | "oidc-usermodel-property-mapper", 1432 | "oidc-sha256-pairwise-sub-mapper", 1433 | "saml-user-attribute-mapper", 1434 | "saml-role-list-mapper" 1435 | ] 1436 | } 1437 | }, 1438 | { 1439 | "id": "b0ff5199-0e1f-451e-af8d-bfd315a48054", 1440 | "name": "Consent Required", 1441 | "providerId": "consent-required", 1442 | "subType": "anonymous", 1443 | "subComponents": {}, 1444 | "config": {} 1445 | }, 1446 | { 1447 | "id": "320fa7c7-0dcc-47ca-bb6f-79ee80ad5e18", 1448 | "name": "Allowed Client Scopes", 1449 | "providerId": "allowed-client-templates", 1450 | "subType": "authenticated", 1451 | "subComponents": {}, 1452 | "config": { 1453 | "allow-default-scopes": [ 1454 | "true" 1455 | ] 1456 | } 1457 | }, 1458 | { 1459 | "id": "048625f1-72eb-4e86-91eb-e57496f89d72", 1460 | "name": "Full Scope Disabled", 1461 | "providerId": "scope", 1462 | "subType": "anonymous", 1463 | "subComponents": {}, 1464 | "config": {} 1465 | }, 1466 | { 1467 | "id": "0dc0367f-65a3-43bd-af15-5480894bc932", 1468 | "name": "Trusted Hosts", 1469 | "providerId": "trusted-hosts", 1470 | "subType": "anonymous", 1471 | "subComponents": {}, 1472 | "config": { 1473 | "host-sending-registration-request-must-match": [ 1474 | "true" 1475 | ], 1476 | "client-uris-must-match": [ 1477 | "true" 1478 | ] 1479 | } 1480 | }, 1481 | { 1482 | "id": "123e9302-b4b2-4169-b61c-ee2f0b01424c", 1483 | "name": "Allowed Protocol Mapper Types", 1484 | "providerId": "allowed-protocol-mappers", 1485 | "subType": "authenticated", 1486 | "subComponents": {}, 1487 | "config": { 1488 | "allowed-protocol-mapper-types": [ 1489 | "oidc-address-mapper", 1490 | "saml-user-property-mapper", 1491 | "saml-role-list-mapper", 1492 | "saml-user-attribute-mapper", 1493 | "oidc-usermodel-property-mapper", 1494 | "oidc-usermodel-attribute-mapper", 1495 | "oidc-sha256-pairwise-sub-mapper", 1496 | "oidc-full-name-mapper" 1497 | ] 1498 | } 1499 | } 1500 | ], 1501 | "org.keycloak.keys.KeyProvider": [ 1502 | { 1503 | "id": "3f771cd8-6c8d-4c5e-b618-ead0aa8ee01e", 1504 | "name": "hmac-generated", 1505 | "providerId": "hmac-generated", 1506 | "subComponents": {}, 1507 | "config": { 1508 | "priority": [ 1509 | "100" 1510 | ], 1511 | "algorithm": [ 1512 | "HS256" 1513 | ] 1514 | } 1515 | }, 1516 | { 1517 | "id": "a6a6d6f3-3724-41ca-bb22-fd29b481a1aa", 1518 | "name": "aes-generated", 1519 | "providerId": "aes-generated", 1520 | "subComponents": {}, 1521 | "config": { 1522 | "priority": [ 1523 | "100" 1524 | ] 1525 | } 1526 | }, 1527 | { 1528 | "id": "8ec8f2a3-4e52-4327-9fb5-8f666e755a6f", 1529 | "name": "rsa-generated", 1530 | "providerId": "rsa-generated", 1531 | "subComponents": {}, 1532 | "config": { 1533 | "priority": [ 1534 | "100" 1535 | ] 1536 | } 1537 | } 1538 | ] 1539 | }, 1540 | "internationalizationEnabled": false, 1541 | "supportedLocales": [], 1542 | "authenticationFlows": [ 1543 | { 1544 | "id": "07cf3a11-f1c1-4880-8ce4-8786990c3c0f", 1545 | "alias": "Account verification options", 1546 | "description": "Method with which to verity the existing account", 1547 | "providerId": "basic-flow", 1548 | "topLevel": false, 1549 | "builtIn": true, 1550 | "authenticationExecutions": [ 1551 | { 1552 | "authenticator": "idp-email-verification", 1553 | "requirement": "ALTERNATIVE", 1554 | "priority": 10, 1555 | "userSetupAllowed": false, 1556 | "autheticatorFlow": false 1557 | }, 1558 | { 1559 | "requirement": "ALTERNATIVE", 1560 | "priority": 20, 1561 | "flowAlias": "Verify Existing Account by Re-authentication", 1562 | "userSetupAllowed": false, 1563 | "autheticatorFlow": true 1564 | } 1565 | ] 1566 | }, 1567 | { 1568 | "id": "c8c4f771-7c8b-4a96-8e13-b18b62ad263c", 1569 | "alias": "Authentication Options", 1570 | "description": "Authentication options.", 1571 | "providerId": "basic-flow", 1572 | "topLevel": false, 1573 | "builtIn": true, 1574 | "authenticationExecutions": [ 1575 | { 1576 | "authenticator": "basic-auth", 1577 | "requirement": "REQUIRED", 1578 | "priority": 10, 1579 | "userSetupAllowed": false, 1580 | "autheticatorFlow": false 1581 | }, 1582 | { 1583 | "authenticator": "basic-auth-otp", 1584 | "requirement": "DISABLED", 1585 | "priority": 20, 1586 | "userSetupAllowed": false, 1587 | "autheticatorFlow": false 1588 | }, 1589 | { 1590 | "authenticator": "auth-spnego", 1591 | "requirement": "DISABLED", 1592 | "priority": 30, 1593 | "userSetupAllowed": false, 1594 | "autheticatorFlow": false 1595 | } 1596 | ] 1597 | }, 1598 | { 1599 | "id": "2e32167d-3e6e-4869-861f-3e67af5cd433", 1600 | "alias": "Browser - Conditional OTP", 1601 | "description": "Flow to determine if the OTP is required for the authentication", 1602 | "providerId": "basic-flow", 1603 | "topLevel": false, 1604 | "builtIn": true, 1605 | "authenticationExecutions": [ 1606 | { 1607 | "authenticator": "conditional-user-configured", 1608 | "requirement": "REQUIRED", 1609 | "priority": 10, 1610 | "userSetupAllowed": false, 1611 | "autheticatorFlow": false 1612 | }, 1613 | { 1614 | "authenticator": "auth-otp-form", 1615 | "requirement": "REQUIRED", 1616 | "priority": 20, 1617 | "userSetupAllowed": false, 1618 | "autheticatorFlow": false 1619 | } 1620 | ] 1621 | }, 1622 | { 1623 | "id": "f3459fe4-6b06-4c44-a3b6-129d9123aa32", 1624 | "alias": "Direct Grant - Conditional OTP", 1625 | "description": "Flow to determine if the OTP is required for the authentication", 1626 | "providerId": "basic-flow", 1627 | "topLevel": false, 1628 | "builtIn": true, 1629 | "authenticationExecutions": [ 1630 | { 1631 | "authenticator": "conditional-user-configured", 1632 | "requirement": "REQUIRED", 1633 | "priority": 10, 1634 | "userSetupAllowed": false, 1635 | "autheticatorFlow": false 1636 | }, 1637 | { 1638 | "authenticator": "direct-grant-validate-otp", 1639 | "requirement": "REQUIRED", 1640 | "priority": 20, 1641 | "userSetupAllowed": false, 1642 | "autheticatorFlow": false 1643 | } 1644 | ] 1645 | }, 1646 | { 1647 | "id": "0d5a3a89-2b39-4002-ad0c-71fdd6323eac", 1648 | "alias": "First broker login - Conditional OTP", 1649 | "description": "Flow to determine if the OTP is required for the authentication", 1650 | "providerId": "basic-flow", 1651 | "topLevel": false, 1652 | "builtIn": true, 1653 | "authenticationExecutions": [ 1654 | { 1655 | "authenticator": "conditional-user-configured", 1656 | "requirement": "REQUIRED", 1657 | "priority": 10, 1658 | "userSetupAllowed": false, 1659 | "autheticatorFlow": false 1660 | }, 1661 | { 1662 | "authenticator": "auth-otp-form", 1663 | "requirement": "REQUIRED", 1664 | "priority": 20, 1665 | "userSetupAllowed": false, 1666 | "autheticatorFlow": false 1667 | } 1668 | ] 1669 | }, 1670 | { 1671 | "id": "31b4a7fd-a545-4468-b0c0-3b076c55b7f2", 1672 | "alias": "Handle Existing Account", 1673 | "description": "Handle what to do if there is existing account with same email/username like authenticated identity provider", 1674 | "providerId": "basic-flow", 1675 | "topLevel": false, 1676 | "builtIn": true, 1677 | "authenticationExecutions": [ 1678 | { 1679 | "authenticator": "idp-confirm-link", 1680 | "requirement": "REQUIRED", 1681 | "priority": 10, 1682 | "userSetupAllowed": false, 1683 | "autheticatorFlow": false 1684 | }, 1685 | { 1686 | "requirement": "REQUIRED", 1687 | "priority": 20, 1688 | "flowAlias": "Account verification options", 1689 | "userSetupAllowed": false, 1690 | "autheticatorFlow": true 1691 | } 1692 | ] 1693 | }, 1694 | { 1695 | "id": "2373366f-3a78-4f2f-8ef6-de8dc1513ad0", 1696 | "alias": "Reset - Conditional OTP", 1697 | "description": "Flow to determine if the OTP should be reset or not. Set to REQUIRED to force.", 1698 | "providerId": "basic-flow", 1699 | "topLevel": false, 1700 | "builtIn": true, 1701 | "authenticationExecutions": [ 1702 | { 1703 | "authenticator": "conditional-user-configured", 1704 | "requirement": "REQUIRED", 1705 | "priority": 10, 1706 | "userSetupAllowed": false, 1707 | "autheticatorFlow": false 1708 | }, 1709 | { 1710 | "authenticator": "reset-otp", 1711 | "requirement": "REQUIRED", 1712 | "priority": 20, 1713 | "userSetupAllowed": false, 1714 | "autheticatorFlow": false 1715 | } 1716 | ] 1717 | }, 1718 | { 1719 | "id": "14afc825-2e21-4e53-b92b-21ba0f577ae9", 1720 | "alias": "User creation or linking", 1721 | "description": "Flow for the existing/non-existing user alternatives", 1722 | "providerId": "basic-flow", 1723 | "topLevel": false, 1724 | "builtIn": true, 1725 | "authenticationExecutions": [ 1726 | { 1727 | "authenticatorConfig": "create unique user config", 1728 | "authenticator": "idp-create-user-if-unique", 1729 | "requirement": "ALTERNATIVE", 1730 | "priority": 10, 1731 | "userSetupAllowed": false, 1732 | "autheticatorFlow": false 1733 | }, 1734 | { 1735 | "requirement": "ALTERNATIVE", 1736 | "priority": 20, 1737 | "flowAlias": "Handle Existing Account", 1738 | "userSetupAllowed": false, 1739 | "autheticatorFlow": true 1740 | } 1741 | ] 1742 | }, 1743 | { 1744 | "id": "9f637600-1b80-409b-980c-e4f933b63129", 1745 | "alias": "Verify Existing Account by Re-authentication", 1746 | "description": "Reauthentication of existing account", 1747 | "providerId": "basic-flow", 1748 | "topLevel": false, 1749 | "builtIn": true, 1750 | "authenticationExecutions": [ 1751 | { 1752 | "authenticator": "idp-username-password-form", 1753 | "requirement": "REQUIRED", 1754 | "priority": 10, 1755 | "userSetupAllowed": false, 1756 | "autheticatorFlow": false 1757 | }, 1758 | { 1759 | "requirement": "CONDITIONAL", 1760 | "priority": 20, 1761 | "flowAlias": "First broker login - Conditional OTP", 1762 | "userSetupAllowed": false, 1763 | "autheticatorFlow": true 1764 | } 1765 | ] 1766 | }, 1767 | { 1768 | "id": "e73eb83f-97c7-4774-b5ad-d8f5df5216eb", 1769 | "alias": "browser", 1770 | "description": "browser based authentication", 1771 | "providerId": "basic-flow", 1772 | "topLevel": true, 1773 | "builtIn": true, 1774 | "authenticationExecutions": [ 1775 | { 1776 | "authenticator": "auth-cookie", 1777 | "requirement": "ALTERNATIVE", 1778 | "priority": 10, 1779 | "userSetupAllowed": false, 1780 | "autheticatorFlow": false 1781 | }, 1782 | { 1783 | "authenticator": "auth-spnego", 1784 | "requirement": "DISABLED", 1785 | "priority": 20, 1786 | "userSetupAllowed": false, 1787 | "autheticatorFlow": false 1788 | }, 1789 | { 1790 | "authenticator": "identity-provider-redirector", 1791 | "requirement": "ALTERNATIVE", 1792 | "priority": 25, 1793 | "userSetupAllowed": false, 1794 | "autheticatorFlow": false 1795 | }, 1796 | { 1797 | "requirement": "ALTERNATIVE", 1798 | "priority": 30, 1799 | "flowAlias": "forms", 1800 | "userSetupAllowed": false, 1801 | "autheticatorFlow": true 1802 | } 1803 | ] 1804 | }, 1805 | { 1806 | "id": "3b1bd79b-a885-42ec-86a5-d81936164db6", 1807 | "alias": "clients", 1808 | "description": "Base authentication for clients", 1809 | "providerId": "client-flow", 1810 | "topLevel": true, 1811 | "builtIn": true, 1812 | "authenticationExecutions": [ 1813 | { 1814 | "authenticator": "client-secret", 1815 | "requirement": "ALTERNATIVE", 1816 | "priority": 10, 1817 | "userSetupAllowed": false, 1818 | "autheticatorFlow": false 1819 | }, 1820 | { 1821 | "authenticator": "client-jwt", 1822 | "requirement": "ALTERNATIVE", 1823 | "priority": 20, 1824 | "userSetupAllowed": false, 1825 | "autheticatorFlow": false 1826 | }, 1827 | { 1828 | "authenticator": "client-secret-jwt", 1829 | "requirement": "ALTERNATIVE", 1830 | "priority": 30, 1831 | "userSetupAllowed": false, 1832 | "autheticatorFlow": false 1833 | }, 1834 | { 1835 | "authenticator": "client-x509", 1836 | "requirement": "ALTERNATIVE", 1837 | "priority": 40, 1838 | "userSetupAllowed": false, 1839 | "autheticatorFlow": false 1840 | } 1841 | ] 1842 | }, 1843 | { 1844 | "id": "00fc22c8-def9-4172-a99f-8a4db0126feb", 1845 | "alias": "direct grant", 1846 | "description": "OpenID Connect Resource Owner Grant", 1847 | "providerId": "basic-flow", 1848 | "topLevel": true, 1849 | "builtIn": true, 1850 | "authenticationExecutions": [ 1851 | { 1852 | "authenticator": "direct-grant-validate-username", 1853 | "requirement": "REQUIRED", 1854 | "priority": 10, 1855 | "userSetupAllowed": false, 1856 | "autheticatorFlow": false 1857 | }, 1858 | { 1859 | "authenticator": "direct-grant-validate-password", 1860 | "requirement": "REQUIRED", 1861 | "priority": 20, 1862 | "userSetupAllowed": false, 1863 | "autheticatorFlow": false 1864 | }, 1865 | { 1866 | "requirement": "CONDITIONAL", 1867 | "priority": 30, 1868 | "flowAlias": "Direct Grant - Conditional OTP", 1869 | "userSetupAllowed": false, 1870 | "autheticatorFlow": true 1871 | } 1872 | ] 1873 | }, 1874 | { 1875 | "id": "08e01db8-738c-46d8-8a38-077ac294051b", 1876 | "alias": "docker auth", 1877 | "description": "Used by Docker clients to authenticate against the IDP", 1878 | "providerId": "basic-flow", 1879 | "topLevel": true, 1880 | "builtIn": true, 1881 | "authenticationExecutions": [ 1882 | { 1883 | "authenticator": "docker-http-basic-authenticator", 1884 | "requirement": "REQUIRED", 1885 | "priority": 10, 1886 | "userSetupAllowed": false, 1887 | "autheticatorFlow": false 1888 | } 1889 | ] 1890 | }, 1891 | { 1892 | "id": "24982e99-953e-4504-b707-ba5ecd88295c", 1893 | "alias": "first broker login", 1894 | "description": "Actions taken after first broker login with identity provider account, which is not yet linked to any Keycloak account", 1895 | "providerId": "basic-flow", 1896 | "topLevel": true, 1897 | "builtIn": true, 1898 | "authenticationExecutions": [ 1899 | { 1900 | "authenticatorConfig": "review profile config", 1901 | "authenticator": "idp-review-profile", 1902 | "requirement": "REQUIRED", 1903 | "priority": 10, 1904 | "userSetupAllowed": false, 1905 | "autheticatorFlow": false 1906 | }, 1907 | { 1908 | "requirement": "REQUIRED", 1909 | "priority": 20, 1910 | "flowAlias": "User creation or linking", 1911 | "userSetupAllowed": false, 1912 | "autheticatorFlow": true 1913 | } 1914 | ] 1915 | }, 1916 | { 1917 | "id": "9aa59184-1366-4628-87db-55b17c4bef51", 1918 | "alias": "forms", 1919 | "description": "Username, password, otp and other auth forms.", 1920 | "providerId": "basic-flow", 1921 | "topLevel": false, 1922 | "builtIn": true, 1923 | "authenticationExecutions": [ 1924 | { 1925 | "authenticator": "auth-username-password-form", 1926 | "requirement": "REQUIRED", 1927 | "priority": 10, 1928 | "userSetupAllowed": false, 1929 | "autheticatorFlow": false 1930 | }, 1931 | { 1932 | "requirement": "CONDITIONAL", 1933 | "priority": 20, 1934 | "flowAlias": "Browser - Conditional OTP", 1935 | "userSetupAllowed": false, 1936 | "autheticatorFlow": true 1937 | } 1938 | ] 1939 | }, 1940 | { 1941 | "id": "43cfe0dc-6439-404e-9a70-fd1ec1f616ca", 1942 | "alias": "http challenge", 1943 | "description": "An authentication flow based on challenge-response HTTP Authentication Schemes", 1944 | "providerId": "basic-flow", 1945 | "topLevel": true, 1946 | "builtIn": true, 1947 | "authenticationExecutions": [ 1948 | { 1949 | "authenticator": "no-cookie-redirect", 1950 | "requirement": "REQUIRED", 1951 | "priority": 10, 1952 | "userSetupAllowed": false, 1953 | "autheticatorFlow": false 1954 | }, 1955 | { 1956 | "requirement": "REQUIRED", 1957 | "priority": 20, 1958 | "flowAlias": "Authentication Options", 1959 | "userSetupAllowed": false, 1960 | "autheticatorFlow": true 1961 | } 1962 | ] 1963 | }, 1964 | { 1965 | "id": "e1b50ae2-d05f-4f6e-919c-778bc57757fb", 1966 | "alias": "registration", 1967 | "description": "registration flow", 1968 | "providerId": "basic-flow", 1969 | "topLevel": true, 1970 | "builtIn": true, 1971 | "authenticationExecutions": [ 1972 | { 1973 | "authenticator": "registration-page-form", 1974 | "requirement": "REQUIRED", 1975 | "priority": 10, 1976 | "flowAlias": "registration form", 1977 | "userSetupAllowed": false, 1978 | "autheticatorFlow": true 1979 | } 1980 | ] 1981 | }, 1982 | { 1983 | "id": "19dd6a10-a4c0-4a6d-ab9d-b869a41aef0b", 1984 | "alias": "registration form", 1985 | "description": "registration form", 1986 | "providerId": "form-flow", 1987 | "topLevel": false, 1988 | "builtIn": true, 1989 | "authenticationExecutions": [ 1990 | { 1991 | "authenticator": "registration-user-creation", 1992 | "requirement": "REQUIRED", 1993 | "priority": 20, 1994 | "userSetupAllowed": false, 1995 | "autheticatorFlow": false 1996 | }, 1997 | { 1998 | "authenticator": "registration-profile-action", 1999 | "requirement": "REQUIRED", 2000 | "priority": 40, 2001 | "userSetupAllowed": false, 2002 | "autheticatorFlow": false 2003 | }, 2004 | { 2005 | "authenticator": "registration-password-action", 2006 | "requirement": "REQUIRED", 2007 | "priority": 50, 2008 | "userSetupAllowed": false, 2009 | "autheticatorFlow": false 2010 | }, 2011 | { 2012 | "authenticator": "registration-recaptcha-action", 2013 | "requirement": "DISABLED", 2014 | "priority": 60, 2015 | "userSetupAllowed": false, 2016 | "autheticatorFlow": false 2017 | } 2018 | ] 2019 | }, 2020 | { 2021 | "id": "1e07da95-56ff-41f8-8142-f141c3255e8d", 2022 | "alias": "reset credentials", 2023 | "description": "Reset credentials for a user if they forgot their password or something", 2024 | "providerId": "basic-flow", 2025 | "topLevel": true, 2026 | "builtIn": true, 2027 | "authenticationExecutions": [ 2028 | { 2029 | "authenticator": "reset-credentials-choose-user", 2030 | "requirement": "REQUIRED", 2031 | "priority": 10, 2032 | "userSetupAllowed": false, 2033 | "autheticatorFlow": false 2034 | }, 2035 | { 2036 | "authenticator": "reset-credential-email", 2037 | "requirement": "REQUIRED", 2038 | "priority": 20, 2039 | "userSetupAllowed": false, 2040 | "autheticatorFlow": false 2041 | }, 2042 | { 2043 | "authenticator": "reset-password", 2044 | "requirement": "REQUIRED", 2045 | "priority": 30, 2046 | "userSetupAllowed": false, 2047 | "autheticatorFlow": false 2048 | }, 2049 | { 2050 | "requirement": "CONDITIONAL", 2051 | "priority": 40, 2052 | "flowAlias": "Reset - Conditional OTP", 2053 | "userSetupAllowed": false, 2054 | "autheticatorFlow": true 2055 | } 2056 | ] 2057 | }, 2058 | { 2059 | "id": "de8aa877-cb96-438e-8bec-3a2c5936441a", 2060 | "alias": "saml ecp", 2061 | "description": "SAML ECP Profile Authentication Flow", 2062 | "providerId": "basic-flow", 2063 | "topLevel": true, 2064 | "builtIn": true, 2065 | "authenticationExecutions": [ 2066 | { 2067 | "authenticator": "http-basic-authenticator", 2068 | "requirement": "REQUIRED", 2069 | "priority": 10, 2070 | "userSetupAllowed": false, 2071 | "autheticatorFlow": false 2072 | } 2073 | ] 2074 | } 2075 | ], 2076 | "authenticatorConfig": [ 2077 | { 2078 | "id": "c03e08b2-cc90-4955-95ba-94045273b392", 2079 | "alias": "create unique user config", 2080 | "config": { 2081 | "require.password.update.after.registration": "false" 2082 | } 2083 | }, 2084 | { 2085 | "id": "ce7eb5e3-c69b-4555-a082-75c603e0e4ff", 2086 | "alias": "review profile config", 2087 | "config": { 2088 | "update.profile.on.first.login": "missing" 2089 | } 2090 | } 2091 | ], 2092 | "requiredActions": [ 2093 | { 2094 | "alias": "CONFIGURE_TOTP", 2095 | "name": "Configure OTP", 2096 | "providerId": "CONFIGURE_TOTP", 2097 | "enabled": true, 2098 | "defaultAction": false, 2099 | "priority": 10, 2100 | "config": {} 2101 | }, 2102 | { 2103 | "alias": "terms_and_conditions", 2104 | "name": "Terms and Conditions", 2105 | "providerId": "terms_and_conditions", 2106 | "enabled": false, 2107 | "defaultAction": false, 2108 | "priority": 20, 2109 | "config": {} 2110 | }, 2111 | { 2112 | "alias": "UPDATE_PASSWORD", 2113 | "name": "Update Password", 2114 | "providerId": "UPDATE_PASSWORD", 2115 | "enabled": true, 2116 | "defaultAction": false, 2117 | "priority": 30, 2118 | "config": {} 2119 | }, 2120 | { 2121 | "alias": "UPDATE_PROFILE", 2122 | "name": "Update Profile", 2123 | "providerId": "UPDATE_PROFILE", 2124 | "enabled": true, 2125 | "defaultAction": false, 2126 | "priority": 40, 2127 | "config": {} 2128 | }, 2129 | { 2130 | "alias": "VERIFY_EMAIL", 2131 | "name": "Verify Email", 2132 | "providerId": "VERIFY_EMAIL", 2133 | "enabled": true, 2134 | "defaultAction": false, 2135 | "priority": 50, 2136 | "config": {} 2137 | }, 2138 | { 2139 | "alias": "update_user_locale", 2140 | "name": "Update User Locale", 2141 | "providerId": "update_user_locale", 2142 | "enabled": true, 2143 | "defaultAction": false, 2144 | "priority": 1000, 2145 | "config": {} 2146 | } 2147 | ], 2148 | "browserFlow": "browser", 2149 | "registrationFlow": "registration", 2150 | "directGrantFlow": "direct grant", 2151 | "resetCredentialsFlow": "reset credentials", 2152 | "clientAuthenticationFlow": "clients", 2153 | "dockerAuthenticationFlow": "docker auth", 2154 | "attributes": {}, 2155 | "keycloakVersion": "11.0.0", 2156 | "userManagedAccessAllowed": false 2157 | } -------------------------------------------------------------------------------- /microservice-consumer/.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/ -------------------------------------------------------------------------------- /microservice-consumer/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /microservice-consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liqili/spring-microservice-oauth2-keycloak-starter/bac24c284d8412a0b844ac4dbd90e4c43d375927/microservice-consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /microservice-consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /microservice-consumer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine as mvn-build 2 | WORKDIR /app/build 3 | COPY ./src ./src 4 | COPY pom.xml . 5 | COPY .mvn .mvn 6 | COPY mvnw . 7 | RUN ./mvnw clean install -Dmaven.test.skip=true 8 | 9 | FROM openjdk:8-jre-alpine 10 | WORKDIR /app 11 | COPY --from=mvn-build /app/build/target/*.jar ./spring-app.jar 12 | CMD ["java", "-jar", "/app/spring-app.jar"] 13 | 14 | -------------------------------------------------------------------------------- /microservice-consumer/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 | # Maven 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 Mingw, 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 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /microservice-consumer/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 Maven 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 keystroke 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 set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /microservice-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.3.4.RELEASE 10 | 11 | 12 | com.euroka 13 | microservice-consumer 14 | 0.0.1-SNAPSHOT 15 | microservice-consumer 16 | Consumer Micro service 17 | 18 | 19 | 1.8 20 | Hoxton.SR8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-netflix-eureka-client 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-oauth2-client 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-starter-security 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-oauth2-resource-server 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-test 48 | test 49 | 50 | 51 | org.junit.vintage 52 | junit-vintage-engine 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.cloud 62 | spring-cloud-dependencies 63 | ${spring-cloud.version} 64 | pom 65 | import 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | org.springframework.boot 74 | spring-boot-maven-plugin 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /microservice-consumer/src/main/java/com/euroka/producer/ConsumerResourceApplication.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ConsumerResourceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ConsumerResourceApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /microservice-consumer/src/main/java/com/euroka/producer/OAuth2ResourceServerConfig.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 5 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 6 | 7 | @Configuration 8 | public class OAuth2ResourceServerConfig extends WebSecurityConfigurerAdapter { 9 | 10 | @Override 11 | protected void configure(HttpSecurity http) throws Exception { 12 | http.authorizeRequests() 13 | .anyRequest().authenticated() 14 | .and() 15 | .oauth2Login() 16 | .and() 17 | .oauth2ResourceServer() 18 | .jwt(); 19 | } 20 | } -------------------------------------------------------------------------------- /microservice-consumer/src/main/java/com/euroka/producer/TestController.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.springframework.http.HttpHeaders; 4 | import org.springframework.web.bind.annotation.RequestHeader; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | public class TestController { 11 | 12 | @RequestMapping(method = RequestMethod.GET, value = "/api/consume/") 13 | public String getTokenDetails(@RequestHeader HttpHeaders headers) { 14 | return headers.toString(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /microservice-consumer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | debug: true 2 | server: 3 | port: 9080 4 | 5 | eureka: 6 | client: 7 | serviceUrl: 8 | defaultZone: http://localhost:9091/eureka/ 9 | keycloak-client: 10 | server-url: http://localhost:18080/auth 11 | realm: spring-micro-main 12 | spring: 13 | application: 14 | name: microservice-consumer 15 | security: 16 | oauth2: 17 | client: 18 | registration: 19 | keycloak: 20 | provider: keycloak 21 | client-id: spring-micro-consumer 22 | client-secret: b2678444-3e56-466d-b035-a6109ca686ca 23 | authorization-grant-type: authorization_code 24 | redirect-uri: http://localhost:9080/login/oauth2/code/keycloak 25 | scope: openid 26 | provider: 27 | keycloak: 28 | authorization-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/auth 29 | token-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/token 30 | user-info-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/userinfo 31 | jwk-set-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/certs 32 | user-name-attribute: name 33 | user-info-authentication-method: header 34 | resourceserver: 35 | jwt: 36 | jwk-set-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/certs 37 | 38 | -------------------------------------------------------------------------------- /microservice-consumer/src/test/java/com/euroka/producer/ConsumerResourceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | public class ConsumerResourceApplicationTests { 8 | 9 | @Test 10 | public void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /microservice-producer/.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/ -------------------------------------------------------------------------------- /microservice-producer/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /microservice-producer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liqili/spring-microservice-oauth2-keycloak-starter/bac24c284d8412a0b844ac4dbd90e4c43d375927/microservice-producer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /microservice-producer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /microservice-producer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine as mvn-build 2 | WORKDIR /app/build 3 | COPY ./src ./src 4 | COPY pom.xml . 5 | COPY .mvn .mvn 6 | COPY mvnw . 7 | RUN ./mvnw clean install -Dmaven.test.skip=true 8 | 9 | FROM openjdk:8-jre-alpine 10 | WORKDIR /app 11 | COPY --from=mvn-build /app/build/target/*.jar ./spring-app.jar 12 | CMD ["java", "-jar", "/app/spring-app.jar"] 13 | 14 | -------------------------------------------------------------------------------- /microservice-producer/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 | # Maven 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 Mingw, 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 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /microservice-producer/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 Maven 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 keystroke 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 set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /microservice-producer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.3.4.RELEASE 10 | 11 | 12 | com.euroka 13 | microservice-producer 14 | 0.0.1-SNAPSHOT 15 | microservice-producer 16 | Producer Micro service 17 | 18 | 19 | 1.8 20 | Hoxton.SR8 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter-netflix-eureka-client 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-oauth2-client 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-starter-security 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-oauth2-resource-server 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-test 48 | test 49 | 50 | 51 | org.junit.vintage 52 | junit-vintage-engine 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.cloud 62 | spring-cloud-dependencies 63 | ${spring-cloud.version} 64 | pom 65 | import 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | org.springframework.boot 74 | spring-boot-maven-plugin 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /microservice-producer/src/main/java/com/euroka/producer/OAuth2ResourceServerConfig.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 5 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 6 | 7 | @Configuration 8 | public class OAuth2ResourceServerConfig extends WebSecurityConfigurerAdapter { 9 | 10 | @Override 11 | protected void configure(HttpSecurity http) throws Exception { 12 | http.authorizeRequests() 13 | .anyRequest().authenticated() 14 | .and() 15 | .oauth2Login() 16 | .and() 17 | .oauth2ResourceServer() 18 | .jwt(); 19 | } 20 | } -------------------------------------------------------------------------------- /microservice-producer/src/main/java/com/euroka/producer/ProducerResourceApplication.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProducerResourceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProducerResourceApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /microservice-producer/src/main/java/com/euroka/producer/TestController.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.springframework.http.HttpHeaders; 4 | import org.springframework.web.bind.annotation.RequestHeader; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | public class TestController { 11 | 12 | @RequestMapping(method = RequestMethod.GET, value = "/api/produce/") 13 | public String getTokenDetails(@RequestHeader HttpHeaders headers) { 14 | return headers.toString(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /microservice-producer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | debug: true 2 | server: 3 | port: 9081 4 | 5 | eureka: 6 | client: 7 | serviceUrl: 8 | defaultZone: http://localhost:9091/eureka/ 9 | keycloak-client: 10 | server-url: http://localhost:18080/auth 11 | realm: spring-micro-main 12 | spring: 13 | application: 14 | name: microservice-producer 15 | security: 16 | oauth2: 17 | client: 18 | registration: 19 | keycloak: 20 | provider: keycloak 21 | client-id: spring-micro-producer 22 | client-secret: 4362afba-b98d-499d-94fd-1f0766b0c9ba 23 | authorization-grant-type: authorization_code 24 | redirect-uri: http://localhost:9081/login/oauth2/code/keycloak 25 | scope: openid 26 | provider: 27 | keycloak: 28 | authorization-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/auth 29 | token-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/token 30 | user-info-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/userinfo 31 | jwk-set-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/certs 32 | user-name-attribute: name 33 | user-info-authentication-method: header 34 | resourceserver: 35 | jwt: 36 | jwk-set-uri: ${keycloak-client.server-url}/realms/${keycloak-client.realm}/protocol/openid-connect/certs 37 | 38 | -------------------------------------------------------------------------------- /microservice-producer/src/test/java/com/euroka/producer/ProducerResourceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.euroka.producer; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | public class ProducerResourceApplicationTests { 8 | 9 | @Test 10 | public void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | com.euroka 8 | spring-microservice-oauth2-keycloak-starter 9 | 1.0-SNAPSHOT 10 | pom 11 | spring-microservice-oauth2-keycloak-starter 12 | 13 | 14 | 15 | api-gateway 16 | eureka-server 17 | microservice-consumer 18 | microservice-producer 19 | 20 | 21 | 22 | 23 | --------------------------------------------------------------------------------