From 2d9020b186e010a9a992e8deda105175636bd702 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 09:18:06 +0000 Subject: [PATCH 1/8] Bump spring-boot-starter-parent.version from 3.1.5 to 3.2.0 Bumps `spring-boot-starter-parent.version` from 3.1.5 to 3.2.0. Updates `org.springframework.boot:spring-boot-starter-parent` from 3.1.5 to 3.2.0 - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.1.5...v3.2.0) Updates `org.springframework.boot:spring-boot-maven-plugin` from 3.1.5 to 3.2.0 - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.1.5...v3.2.0) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.springframework.boot:spring-boot-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f44d20..e9d7555 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 3.2.3 3.2.3 1.9.21 - 3.1.5 + 3.2.0 0.4.3 0.8.11 0.8.13.RELEASE From 826a155bceeb22cb885693ca84f2d05b5fb5ef07 Mon Sep 17 00:00:00 2001 From: jesperancinha Date: Thu, 14 Dec 2023 22:51:29 +0100 Subject: [PATCH 2/8] enables csrf --- .../auth/config/SecurityConfiguration.kt | 59 ++++++++++--------- .../controller/CameraAuthControllerTest.kt | 1 - 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt index 39cc2b7..fb66d6f 100644 --- a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt +++ b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt @@ -2,7 +2,7 @@ package org.jesperancinha.cameras.auth.config import io.netty.handler.ssl.SslContextBuilder import io.netty.handler.ssl.util.InsecureTrustManagerFactory -import kotlinx.coroutines.* +import kotlinx.coroutines.runBlocking import org.jesperancinha.cameras.auth.dao.UserRepository import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value @@ -11,7 +11,9 @@ import org.springframework.context.annotation.Configuration import org.springframework.http.client.reactive.ReactorClientHttpConnector import org.springframework.security.config.web.server.ServerHttpSecurity import org.springframework.security.core.GrantedAuthority -import org.springframework.security.core.userdetails.* +import org.springframework.security.core.userdetails.MapReactiveUserDetailsService +import org.springframework.security.core.userdetails.User +import org.springframework.security.core.userdetails.UserDetails import org.springframework.security.crypto.bcrypt.BCrypt import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.security.web.server.SecurityWebFilterChain @@ -21,7 +23,6 @@ import org.springframework.web.reactive.function.client.WebClient import reactor.core.publisher.Mono import reactor.netty.http.client.HttpClient import reactor.netty.tcp.SslProvider -import reactor.netty.tcp.TcpClient /** @@ -32,35 +33,40 @@ class SecurityConfiguration { @Bean fun securityWebFilterChain(httpSecurity: ServerHttpSecurity): SecurityWebFilterChain = httpSecurity - .csrf().disable() - .authorizeExchange() - .pathMatchers("/webjars/**") - .permitAll() - .pathMatchers("/logout") - .permitAll() - .pathMatchers("/logout/**") - .permitAll() - .pathMatchers("/v3/**") - .permitAll() - .pathMatchers("/actuator/**") - .permitAll() - .anyExchange() - .authenticated() - .and() - .formLogin() - .and() + .authorizeExchange { exchanges -> + exchanges + .pathMatchers("/webjars/**") + .permitAll() + .pathMatchers("/logout") + .permitAll() + .pathMatchers("/logout/**") + .permitAll() + .pathMatchers("/v3/**") + .permitAll() + .pathMatchers("/actuator/**") + .permitAll() + .anyExchange() + .authenticated() + + } + .formLogin { formLogin -> + formLogin + .loginPage("/login") + } .build() @Bean fun webFluxClient(): WebClient = run { val sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build() - val tcpClient = TcpClient.create().secure { sslContextSpec: SslProvider.SslContextSpec -> - sslContextSpec.sslContext( - sslContext - ) - } - val httpClient: HttpClient = HttpClient.from(tcpClient) + val httpClient: HttpClient = HttpClient.create() + .secure { sslContextSpec: SslProvider.SslContextSpec -> + sslContextSpec.sslContext( + sslContext + ) + } WebClient.builder().clientConnector(ReactorClientHttpConnector(httpClient)).build() + + } @@ -80,7 +86,6 @@ class CustomPasswordEncoder : PasswordEncoder { @Service class UserService @Autowired constructor( val userRepository: UserRepository, - val customPasswordEncoder: CustomPasswordEncoder, @Value("\${hc.auth.guest.user}") val guestUser: String, @Value("\${hc.auth.guest.password}") diff --git a/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt b/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt index 3ae8a1e..8f3906e 100644 --- a/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt +++ b/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt @@ -8,7 +8,6 @@ import io.mockk.every import org.jesperancinha.cameras.auth.dao.BearerToken import org.jesperancinha.cameras.auth.dao.BearerTokenEnriched import org.jesperancinha.cameras.auth.dao.ResAuthorizeBody -import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest From a8e80366a5908f09cbf45f17e5e9727c1c7fc616 Mon Sep 17 00:00:00 2001 From: jesperancinha Date: Thu, 14 Dec 2023 23:22:25 +0100 Subject: [PATCH 3/8] Re-disables csrf --- .../cameraservice/config/MetricsConfiguration.kt | 4 ++-- .../cameras/auth/config/SecurityConfiguration.kt | 1 + .../auth/controller/CameraAuthControllerTest.kt | 6 +++--- hc_wait.sh | 10 +++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/camera-service/src/main/kotlin/org/jesperancinha/cameras/cameraservice/config/MetricsConfiguration.kt b/camera-service/src/main/kotlin/org/jesperancinha/cameras/cameraservice/config/MetricsConfiguration.kt index 9274b76..a2b0fdf 100644 --- a/camera-service/src/main/kotlin/org/jesperancinha/cameras/cameraservice/config/MetricsConfiguration.kt +++ b/camera-service/src/main/kotlin/org/jesperancinha/cameras/cameraservice/config/MetricsConfiguration.kt @@ -60,12 +60,12 @@ class MetricsConfiguration( fun gaugeMetric(meterRegistry: MeterRegistry) = Gauge.builder("camera.image.read.time", last10FileDeltaNSReading) { last10Records -> - logger.debug("$last10FileDeltaNSReading") + logger.debug("{}", last10FileDeltaNSReading) measureNanoTime { runBlocking { cameraService.getImageByteArrayByCameraNumber(cameraNumber) } }.toDouble() .let { record -> last10Records.add(record) if (last10Records.size == 11) { - last10Records.removeFirst() + last10Records.removeAt(0) } logger.info("Refreshed ${last10Records.size} metrics. Last value read is ${last10Records.last()} ns") record diff --git a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt index fb66d6f..a704daa 100644 --- a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt +++ b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt @@ -33,6 +33,7 @@ class SecurityConfiguration { @Bean fun securityWebFilterChain(httpSecurity: ServerHttpSecurity): SecurityWebFilterChain = httpSecurity + .csrf { it.disable() } .authorizeExchange { exchanges -> exchanges .pathMatchers("/webjars/**") diff --git a/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt b/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt index 8f3906e..f0b30e7 100644 --- a/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt +++ b/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt @@ -33,7 +33,7 @@ class CameraAuthControllerTest @Autowired constructor( lateinit var webFluxClient: WebClient @Test - @WithMockUser("admin") + @WithMockUser("guest") fun `should create token by calling service`() { val testCode = UUID.randomUUID() every { @@ -46,7 +46,7 @@ class CameraAuthControllerTest @Autowired constructor( .bodyToMono(ResAuthorizeBody::class.java) } returns Mono.just( ResAuthorizeBody( - "http://localhost:8080?code=$testCode" + "http://localhost:8080/api/v1/cameras/auth?code=$testCode" ) ) val bearerToken = BearerToken( @@ -62,7 +62,7 @@ class CameraAuthControllerTest @Autowired constructor( } returns Mono.just( bearerToken ) - val url = "/api/v1/cameras/auth/?response_type=code&client_id=CAMERA06CLIENTID&scope=admin&state=Ok&redirect_uri=http://localhost:8080" + val url = "/api/v1/cameras/auth?response_type=code&client_id=CAMERA06CLIENTID&scope=admin&state=Ok&redirect_uri=http://localhost:8080/api/v1/cameras/auth" testRestTemplate.getForEntity(url, BearerTokenEnriched::class.java) .shouldNotBeNull() .let { diff --git a/hc_wait.sh b/hc_wait.sh index ddac63e..27c1bc1 100755 --- a/hc_wait.sh +++ b/hc_wait.sh @@ -31,9 +31,9 @@ checkServiceByNameAndMessage graphite 'ok: run: nginx' checkServiceByNameAndMessage kong-database 'database system is ready to accept connections' checkServiceByNameAndMessage nginx 'test is successful' checkServiceByNameAndMessage prometheus 'Starting rule manager...' -checkServiceByNameAndMessage camera-1-service 'Tomcat started on port(s): 8080' -checkServiceByNameAndMessage camera-2-service 'Tomcat started on port(s): 8080' -checkServiceByNameAndMessage camera-3-service 'Tomcat started on port(s): 8080' -checkServiceByNameAndMessage camera-4-service 'Tomcat started on port(s): 8080' -checkServiceByNameAndMessage camera-5-service 'Tomcat started on port(s): 8080' +checkServiceByNameAndMessage camera-1-service 'Tomcat started' +checkServiceByNameAndMessage camera-2-service 'Tomcat started' +checkServiceByNameAndMessage camera-3-service 'Tomcat started' +checkServiceByNameAndMessage camera-4-service 'Tomcat started' +checkServiceByNameAndMessage camera-5-service 'Tomcat started' checkServiceByNameAndMessage openldap 'slapd starting' From 43901dd1f5be013e51f2c5451426fd194bd4e975 Mon Sep 17 00:00:00 2001 From: jesperancinha Date: Fri, 15 Dec 2023 09:03:26 +0100 Subject: [PATCH 4/8] Activates CSRF for tess --- .../cameras/auth/config/SecurityConfiguration.kt | 16 +++++++++++----- .../src/main/resources/application.properties | 1 + .../auth/controller/CameraAuthControllerTest.kt | 7 ++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt index a704daa..bbcc19f 100644 --- a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt +++ b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt @@ -31,9 +31,12 @@ import reactor.netty.tcp.SslProvider @Configuration class SecurityConfiguration { @Bean - fun securityWebFilterChain(httpSecurity: ServerHttpSecurity): SecurityWebFilterChain = - httpSecurity - .csrf { it.disable() } + fun securityWebFilterChain( + @Value("\${hc.csrf.enable:false}") + csrf: Boolean, + httpSecurity: ServerHttpSecurity + ): SecurityWebFilterChain { + val serverHttpSecurityBuilder = httpSecurity .authorizeExchange { exchanges -> exchanges .pathMatchers("/webjars/**") @@ -54,7 +57,12 @@ class SecurityConfiguration { formLogin .loginPage("/login") } + if(!csrf){ + serverHttpSecurityBuilder.csrf { it.disable() } + } + return serverHttpSecurityBuilder .build() + } @Bean fun webFluxClient(): WebClient = run { @@ -66,8 +74,6 @@ class SecurityConfiguration { ) } WebClient.builder().clientConnector(ReactorClientHttpConnector(httpClient)).build() - - } diff --git a/cameras-auth-service/src/main/resources/application.properties b/cameras-auth-service/src/main/resources/application.properties index 9977319..f059ae4 100644 --- a/cameras-auth-service/src/main/resources/application.properties +++ b/cameras-auth-service/src/main/resources/application.properties @@ -21,3 +21,4 @@ hc.auth.oauth.grant_type=authorization_code hc.auth.oauth.url.auth=https://localhost:8443/camera-6-service/api/v1/hc/oauth2/authorize hc.auth.oauth.url.token=https://localhost:8443/camera-6-service/api/v1/hc/oauth2/token hc.auth.guest.validate=false +hc.csrf.enable=false \ No newline at end of file diff --git a/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt b/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt index f0b30e7..cc3028f 100644 --- a/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt +++ b/cameras-auth-service/src/test/kotlin/org/jesperancinha/cameras/auth/controller/CameraAuthControllerTest.kt @@ -23,7 +23,8 @@ import java.util.* @SpringBootTest( webEnvironment = RANDOM_PORT, properties = [ "hc.auth.oauth.provision_key=tra-la-la", - "hc.auth.guest.validate=true"] + "hc.auth.guest.validate=true", + "hc.csrf.enable=true"] ) class CameraAuthControllerTest @Autowired constructor( val testRestTemplate: TestRestTemplate @@ -46,7 +47,7 @@ class CameraAuthControllerTest @Autowired constructor( .bodyToMono(ResAuthorizeBody::class.java) } returns Mono.just( ResAuthorizeBody( - "http://localhost:8080/api/v1/cameras/auth?code=$testCode" + "http://localhost:8080?code=$testCode" ) ) val bearerToken = BearerToken( @@ -62,7 +63,7 @@ class CameraAuthControllerTest @Autowired constructor( } returns Mono.just( bearerToken ) - val url = "/api/v1/cameras/auth?response_type=code&client_id=CAMERA06CLIENTID&scope=admin&state=Ok&redirect_uri=http://localhost:8080/api/v1/cameras/auth" + val url = "/api/v1/cameras/auth/?response_type=code&client_id=CAMERA06CLIENTID&scope=admin&state=Ok&redirect_uri=http://localhost:8080" testRestTemplate.getForEntity(url, BearerTokenEnriched::class.java) .shouldNotBeNull() .let { From dbaf7289707862377df31ca699e34f2b0520ecde Mon Sep 17 00:00:00 2001 From: jesperancinha Date: Fri, 15 Dec 2023 09:11:41 +0100 Subject: [PATCH 5/8] Enables CSRF for everything --- cameras-auth-service/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cameras-auth-service/src/main/resources/application.properties b/cameras-auth-service/src/main/resources/application.properties index f059ae4..2848c6b 100644 --- a/cameras-auth-service/src/main/resources/application.properties +++ b/cameras-auth-service/src/main/resources/application.properties @@ -21,4 +21,4 @@ hc.auth.oauth.grant_type=authorization_code hc.auth.oauth.url.auth=https://localhost:8443/camera-6-service/api/v1/hc/oauth2/authorize hc.auth.oauth.url.token=https://localhost:8443/camera-6-service/api/v1/hc/oauth2/token hc.auth.guest.validate=false -hc.csrf.enable=false \ No newline at end of file +hc.csrf.enable=true \ No newline at end of file From f5e16b72b4b955bf5bc7c4ed06951f8d1902f35e Mon Sep 17 00:00:00 2001 From: jesperancinha Date: Fri, 15 Dec 2023 12:07:45 +0100 Subject: [PATCH 6/8] Disables CSRF again but fixes container order --- Makefile | 4 ++ .../src/main/resources/application.properties | 2 +- docker-compose.yml | 52 ++++++++++++++++++- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e110cb4..6d7be9c 100644 --- a/Makefile +++ b/Makefile @@ -133,6 +133,10 @@ build-graphite: docker-compose -p ${GITHUB_RUN_ID} rm graphite docker-compose -p ${GITHUB_RUN_ID} build --no-cache graphite docker-compose -p ${GITHUB_RUN_ID} up -d graphite +build-kong: + docker-compose -p ${GITHUB_RUN_ID} rm kong + docker-compose -p ${GITHUB_RUN_ID} build --no-cache kong + docker-compose -p ${GITHUB_RUN_ID} up -d kong stop-cameras-auth-service: stop-auth-service status-containers: docker ps diff --git a/cameras-auth-service/src/main/resources/application.properties b/cameras-auth-service/src/main/resources/application.properties index 2848c6b..f059ae4 100644 --- a/cameras-auth-service/src/main/resources/application.properties +++ b/cameras-auth-service/src/main/resources/application.properties @@ -21,4 +21,4 @@ hc.auth.oauth.grant_type=authorization_code hc.auth.oauth.url.auth=https://localhost:8443/camera-6-service/api/v1/hc/oauth2/authorize hc.auth.oauth.url.token=https://localhost:8443/camera-6-service/api/v1/hc/oauth2/token hc.auth.guest.validate=false -hc.csrf.enable=true \ No newline at end of file +hc.csrf.enable=false \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d920299..93171b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,10 @@ services: condition: service_healthy kong: condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8080/api/v1/hc/actuator/health || exit 1"] + interval: 5s + retries: 30 camera-2-service: hostname: camera-2-service @@ -31,6 +35,10 @@ services: condition: service_healthy kong: condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8080/api/v1/hc/actuator/health || exit 1"] + interval: 5s + retries: 30 camera-3-service: hostname: camera-3-service @@ -47,6 +55,10 @@ services: condition: service_healthy kong: condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8080/api/v1/hc/actuator/health || exit 1"] + interval: 5s + retries: 30 camera-4-service: hostname: camera-4-service @@ -63,6 +75,10 @@ services: condition: service_healthy kong: condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8080/api/v1/hc/actuator/health || exit 1"] + interval: 5s + retries: 30 camera-5-service: hostname: camera-5-service @@ -79,6 +95,10 @@ services: condition: service_healthy kong: condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8080/api/v1/hc/actuator/health || exit 1"] + interval: 5s + retries: 30 camera-6-service: hostname: camera-6-service @@ -95,6 +115,10 @@ services: condition: service_healthy kong: condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8080/api/v1/hc/actuator/health || exit 1"] + interval: 5s + retries: 30 kong-database: hostname: kong-database @@ -147,6 +171,10 @@ services: command: "--config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus" expose: - 9090 + healthcheck: + test: ["CMD", "wget", "http://localhost:9090"] + interval: 5s + retries: 30 depends_on: kong-database: condition: service_healthy @@ -161,6 +189,10 @@ services: - ./docker-images/grafana/provisioning/:/etc/grafana/provisioning expose: - 3000 + healthcheck: + test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/3000' || exit 1 + interval: 5s + retries: 30 depends_on: kong-database: condition: service_healthy @@ -186,7 +218,7 @@ services: healthcheck: test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/8001' || exit 1 interval: 5s - retries: 10 + retries: 30 depends_on: kong-database: condition: service_healthy @@ -213,7 +245,7 @@ services: healthcheck: test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/8090' || exit 1 interval: 5s - retries: 10 + retries: 30 depends_on: kong-database: condition: service_healthy @@ -221,6 +253,22 @@ services: condition: service_completed_successfully kong: condition: service_healthy + grafana: + condition: service_healthy + prometheus: + condition: service_healthy + camera-1-service: + condition: service_healthy + camera-2-service: + condition: service_healthy + camera-3-service: + condition: service_healthy + camera-4-service: + condition: service_healthy + camera-5-service: + condition: service_healthy + camera-6-service: + condition: service_healthy graphite: container_name: graphite From c9381d8df4d08f214aba7149b5d7986c3b7c4cc3 Mon Sep 17 00:00:00 2001 From: jesperancinha Date: Fri, 15 Dec 2023 12:10:44 +0100 Subject: [PATCH 7/8] Documentation update --- Readme.md | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/Readme.md b/Readme.md index 09763c5..275cfe7 100644 --- a/Readme.md +++ b/Readme.md @@ -81,23 +81,9 @@ make dcup #### Videos - +- [Custom Metrics with Prometheus by Stack Doctor](https://www.youtube.com/watch?v=XToKHYXSUyc) +- [Getting Started with Kong Ingress Controller for Kubernetes](https://www.youtube.com/watch?v=hrYqGXU-a6E) +- [How to Use Kong Gateway OAuth2 Plugin](https://www.youtube.com/watch?v=AIYIHZbDziI) ## About me From fc0fbb74b911051149024d46aaa344f04348fca0 Mon Sep 17 00:00:00 2001 From: jesperancinha Date: Fri, 15 Dec 2023 12:52:44 +0100 Subject: [PATCH 8/8] Gets login page working --- .../jesperancinha/cameras/auth/CamerasAuthAppLauncher.kt | 4 +++- .../cameras/auth/config/SecurityConfiguration.kt | 6 ++---- .../src/main/resources/application-local.properties | 1 + .../src/main/resources/application.properties | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 cameras-auth-service/src/main/resources/application-local.properties diff --git a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/CamerasAuthAppLauncher.kt b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/CamerasAuthAppLauncher.kt index 66eed6d..7965da5 100644 --- a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/CamerasAuthAppLauncher.kt +++ b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/CamerasAuthAppLauncher.kt @@ -9,7 +9,9 @@ import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.event.ContextRefreshedEvent import org.springframework.context.event.EventListener -import org.springframework.core.env.* +import org.springframework.core.env.AbstractEnvironment +import org.springframework.core.env.EnumerablePropertySource +import org.springframework.core.env.PropertySource import org.springframework.stereotype.Component import java.util.* import java.util.stream.StreamSupport diff --git a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt index bbcc19f..1a14cc2 100644 --- a/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt +++ b/cameras-auth-service/src/main/kotlin/org/jesperancinha/cameras/auth/config/SecurityConfiguration.kt @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.http.client.reactive.ReactorClientHttpConnector +import org.springframework.security.config.Customizer import org.springframework.security.config.web.server.ServerHttpSecurity import org.springframework.security.core.GrantedAuthority import org.springframework.security.core.userdetails.MapReactiveUserDetailsService @@ -53,10 +54,7 @@ class SecurityConfiguration { .authenticated() } - .formLogin { formLogin -> - formLogin - .loginPage("/login") - } + .formLogin(Customizer.withDefaults()) if(!csrf){ serverHttpSecurityBuilder.csrf { it.disable() } } diff --git a/cameras-auth-service/src/main/resources/application-local.properties b/cameras-auth-service/src/main/resources/application-local.properties new file mode 100644 index 0000000..60a372b --- /dev/null +++ b/cameras-auth-service/src/main/resources/application-local.properties @@ -0,0 +1 @@ +PROVISION_KEY=1234567890 \ No newline at end of file diff --git a/cameras-auth-service/src/main/resources/application.properties b/cameras-auth-service/src/main/resources/application.properties index f059ae4..54b7ac9 100644 --- a/cameras-auth-service/src/main/resources/application.properties +++ b/cameras-auth-service/src/main/resources/application.properties @@ -7,7 +7,7 @@ spring.r2dbc.password=kong_password springdoc.show-actuator=true management.endpoints.web.exposure.include=* -spring.webflux.base-path=/api/v1/cameras/auth/ +spring.webflux.base-path=/api/v1/cameras/auth hc.auth.guest.user=guest # Password is guest :)