From 1eefad0efa5eb14e4b917814a4dcce2b6f261a43 Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 06:52:33 +0200 Subject: [PATCH 01/10] refactor(#20): logback refactor profiles --- .../src/main/resources/logback-spring.xml | 50 ++++--------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/refarch-gateway/src/main/resources/logback-spring.xml b/refarch-gateway/src/main/resources/logback-spring.xml index 1494ddd2..cf2f1cbc 100644 --- a/refarch-gateway/src/main/resources/logback-spring.xml +++ b/refarch-gateway/src/main/resources/logback-spring.xml @@ -8,13 +8,14 @@ - + - %date{yyyy.MM.dd HH:mm:ss.SSS} | ${springAppName} | TraceId: %X{traceId:-} | SpanId: %X{spanId:-}] | %level | [%thread] | %logger{0} | [%file : %line] - %msg%n + %date{yyyy.MM.dd HH:mm:ss.SSS} | ${springAppName} | TraceId: %X{traceId:-} | SpanId: %X{spanId:-}] | + %level | [%thread] | %logger{0} | [%file : %line] - %msg%n @@ -23,42 +24,36 @@ - - - - - + - + - + - + - + - + @@ -88,34 +83,9 @@ - - - - - - - - - - - - - - - - - - + From 020c544e1101f7b7058384b51662d87a906f62e1 Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 06:52:57 +0200 Subject: [PATCH 02/10] feat: renovate add labels --- renovate.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 22a99432..aa455ccc 100644 --- a/renovate.json +++ b/renovate.json @@ -1,4 +1,9 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:recommended"] + "extends": [ + "config:recommended" + ], + "labels": [ + "dependencies" + ] } From fa0313e91d4b79122db515b6447a5c805b039f9c Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 06:53:25 +0200 Subject: [PATCH 03/10] typo: README.md fix typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5318b025..90f66f18 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Refarch +# RefArch [![Made with love by it@M][made-with-love-shield]][itm-opensource] -Collection of different reference architecture (Refarch) components developed by it@M. +Collection of different reference architecture (RefArch) components developed by it@M. ## Usage From 6c0bf5d0eeba096df89de230758d82f78abb8cc2 Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 06:55:53 +0200 Subject: [PATCH 04/10] refactor(#20): logback refactor profiles update README.md --- refarch-gateway/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/refarch-gateway/README.md b/refarch-gateway/README.md index 10680e7d..03563b1c 100644 --- a/refarch-gateway/README.md +++ b/refarch-gateway/README.md @@ -20,9 +20,10 @@ Beside the default behaviour there are some special route prefixes which are han ## Profiles -| Profile | Description | -|---------------|---------------------------------------------------------------------------------------------------| -| `no-security` | Disables complete security like authentication, authorization, csrf etc. Routing works as normal. | +| Profile | Description | +|----------------|---------------------------------------------------------------------------------------------------| +| `json-logging` | Switches logging from textual to JSON output. | +| `no-security` | Disables complete security like authentication, authorization, csrf etc. Routing works as normal. | ## Configuration From d0cf22835600326740f3c50e4be1ac400f293cdb Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 06:56:06 +0200 Subject: [PATCH 05/10] typo: README.md fix typos --- refarch-gateway/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refarch-gateway/README.md b/refarch-gateway/README.md index 03563b1c..7348479a 100644 --- a/refarch-gateway/README.md +++ b/refarch-gateway/README.md @@ -1,4 +1,4 @@ -# Refarch Gateway +# RefArch Gateway ## Usage From fc2908516806c31c1ca4db2fbf317969ced744a4 Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 07:08:39 +0200 Subject: [PATCH 06/10] :recycle: #18: refactor hazelcast profiles --- .../WebSessionConfiguration.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java b/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java index e0c070fa..06c41d5b 100644 --- a/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java +++ b/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java @@ -3,10 +3,10 @@ import com.hazelcast.config.Config; import com.hazelcast.config.EvictionPolicy; import com.hazelcast.config.MapConfig; +import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -25,6 +25,7 @@ */ @Configuration @EnableSpringWebSession +@Profile({ "hazelcast-local", "hazelcast-k8s" }) public class WebSessionConfiguration { @Value("${hazelcast.instance:hazl_instance}") @@ -45,15 +46,20 @@ public ServerOAuth2AuthorizedClientRepository authorizedClientRepository() { } @Bean - public ReactiveSessionRepository reactiveSessionRepository(@Qualifier("hazelcastInstance") @Autowired HazelcastInstance hazelcastInstance) { + public ReactiveSessionRepository reactiveSessionRepository(@Autowired HazelcastInstance hazelcastInstance) { final IMap map = hazelcastInstance.getMap(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME); return new ReactiveMapSessionRepository(map); } @Bean - @Profile({ "local", "test" }) + public HazelcastInstance hazelcastInstance(@Autowired final Config config) { + return Hazelcast.getOrCreateHazelcastInstance(config); + } + + @Bean + @Profile({ "hazelcast-local" }) public Config localConfig(@Value( - "${spring.session.timeout}" + "${spring.session.timeout}" ) int timeout) { final var hazelcastConfig = new Config(); hazelcastConfig.setInstanceName(hazelcastInstanceName); @@ -73,7 +79,7 @@ public Config localConfig(@Value( } @Bean - @Profile({ "dev", "kon", "prod" }) + @Profile({ "hazelcast-k8s" }) public Config config(@Value("${spring.session.timeout}") int timeout) { final var hazelcastConfig = new Config(); hazelcastConfig.setInstanceName(hazelcastInstanceName); @@ -94,11 +100,10 @@ public Config config(@Value("${spring.session.timeout}") int timeout) { /** * Adds the session timeout in seconds to the hazelcast configuration. *

- * Since we are creating the map it's important to evict sessions by setting a reasonable value for - * time to live. + * Since we are creating the map it's important to evict sessions by setting a reasonable value for time to live. * * @param hazelcastConfig to add the timeout. - * @param sessionTimeout for security session. + * @param sessionTimeout for security session. */ private void addSessionTimeoutToHazelcastConfig(final Config hazelcastConfig, final int sessionTimeout) { final var sessionConfig = new MapConfig(); From 41d5d572d826a57b96bf359ecb5141c723be0ced Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 07:09:31 +0200 Subject: [PATCH 07/10] :recycle: #18: refactor hazelcast profiles --- refarch-gateway/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/refarch-gateway/README.md b/refarch-gateway/README.md index 7348479a..bd9aea71 100644 --- a/refarch-gateway/README.md +++ b/refarch-gateway/README.md @@ -20,10 +20,12 @@ Beside the default behaviour there are some special route prefixes which are han ## Profiles -| Profile | Description | -|----------------|---------------------------------------------------------------------------------------------------| -| `json-logging` | Switches logging from textual to JSON output. | -| `no-security` | Disables complete security like authentication, authorization, csrf etc. Routing works as normal. | +| Profile | Description | +|-------------------|---------------------------------------------------------------------------------------------------| +| `json-logging` | Switches logging from textual to JSON output. | +| `no-security` | Disables complete security like authentication, authorization, csrf etc. Routing works as normal. | +| `hazelcast-local` | Configures Spring Session Hazelcast for connection via localhost (i.e. local development). | +| `hazelcast-k8s` | Configures Spring Session Hazelcast for usage in Kubernetes/OpenShift cluster. | ## Configuration From db02bec2b9b910dcc6cf1d0f4a8ae0bfa4101981 Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 07:12:02 +0200 Subject: [PATCH 08/10] :art: reformat WebSessionConfiguration --- .../configuration/WebSessionConfiguration.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java b/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java index 06c41d5b..a4790533 100644 --- a/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java +++ b/refarch-gateway/src/main/java/de.muenchen.oss.refarch.gateway/configuration/WebSessionConfiguration.java @@ -59,7 +59,7 @@ public HazelcastInstance hazelcastInstance(@Autowired final Config config) { @Bean @Profile({ "hazelcast-local" }) public Config localConfig(@Value( - "${spring.session.timeout}" + "${spring.session.timeout}" ) int timeout) { final var hazelcastConfig = new Config(); hazelcastConfig.setInstanceName(hazelcastInstanceName); @@ -100,10 +100,11 @@ public Config config(@Value("${spring.session.timeout}") int timeout) { /** * Adds the session timeout in seconds to the hazelcast configuration. *

- * Since we are creating the map it's important to evict sessions by setting a reasonable value for time to live. + * Since we are creating the map it's important to evict sessions by setting a reasonable value for + * time to live. * * @param hazelcastConfig to add the timeout. - * @param sessionTimeout for security session. + * @param sessionTimeout for security session. */ private void addSessionTimeoutToHazelcastConfig(final Config hazelcastConfig, final int sessionTimeout) { final var sessionConfig = new MapConfig(); From fb5c8647a34eae8b40432698167954ab39499498 Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 07:16:51 +0200 Subject: [PATCH 09/10] :recycle: (#22) reformat spring banner --- refarch-gateway/src/main/resources/banner.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/refarch-gateway/src/main/resources/banner.txt b/refarch-gateway/src/main/resources/banner.txt index d9c17921..f4dbbaed 100644 --- a/refarch-gateway/src/main/resources/banner.txt +++ b/refarch-gateway/src/main/resources/banner.txt @@ -1,10 +1,6 @@ --------------------------------------------------------------------------------------------------------------------------------------------------- - ____ __ _ ____ _ - | _ \ ___ / _| __ _ _ __ ___| |__ / ___| __ _| |_ _____ ____ _ _ _ - | |_) / _ \ |_ / _` | '__/ __| '_ \| | _ / _` | __/ _ \ \ /\ / / _` | | | | - | _ < __/ _| (_| | | | (__| | | | |_| | (_| | || __/\ V V / (_| | |_| | - |_| \_\___|_| \__,_|_| \___|_| |_|\____|\__,_|\__\___| \_/\_/ \__,_|\__, | - |___/ + RefArch-Gateway + https://github.com/it-at-m/refarch Application Name : ${spring.application.name} (v${info.application.version}) Spring Boot Version : ${spring-boot.formatted-version} From 31c72e8c5ef0f52388cea63fab795f02dc265da3 Mon Sep 17 00:00:00 2001 From: Simon Hirtreiter Date: Fri, 26 Jul 2024 08:36:54 +0200 Subject: [PATCH 10/10] :art: #20 fix log pattern format --- refarch-gateway/src/main/resources/logback-spring.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/refarch-gateway/src/main/resources/logback-spring.xml b/refarch-gateway/src/main/resources/logback-spring.xml index cf2f1cbc..d3d59236 100644 --- a/refarch-gateway/src/main/resources/logback-spring.xml +++ b/refarch-gateway/src/main/resources/logback-spring.xml @@ -13,10 +13,11 @@ + - %date{yyyy.MM.dd HH:mm:ss.SSS} | ${springAppName} | TraceId: %X{traceId:-} | SpanId: %X{spanId:-}] | - %level | [%thread] | %logger{0} | [%file : %line] - %msg%n + %date{yyyy.MM.dd HH:mm:ss.SSS} | ${springAppName} | TraceId: %X{traceId:-} | SpanId: %X{spanId:-}] | %level | [%thread] | %logger{0} | [%file : %line] - %msg%n +