Skip to content

Commit

Permalink
Merge pull request #6 from NTF-marketplace/apply/config-client
Browse files Browse the repository at this point in the history
Apply/config client
  • Loading branch information
min-96 authored Jul 23, 2024
2 parents 2df6731 + 082446f commit c088626
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 65 deletions.
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ repositories {
mavenCentral()
}

extra["springCloudVersion"] = "2023.0.2"

dependencies {
implementation("org.springframework.cloud:spring-cloud-starter-config")
implementation("org.springframework.boot:spring-boot-starter-oauth2-authorization-server")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
Expand Down Expand Up @@ -53,6 +56,12 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-exporter-zipkin")
}

dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/com/api/auth/config/SecurityConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.builders.WebSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer
import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.web.SecurityFilterChain
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter

Expand Down
29 changes: 29 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#spring:
# cloud:
# config:
# enabled: false
# datasource:
# url: jdbc:postgresql://localhost:5433/auth
# username: auth
# password: auth
# flyway:
# locations: classpath:db/migration
# r2dbc:
# url: r2dbc:postgresql://localhost:5433/auth
# username: auth
# password: auth
#
#jwt:
# rsa-key-path: "rsaKey.json"


spring:
application:
name: auth
config:
import: "optional:configserver:http://localhost:9000"
cloud:
config:
fail-fast: true

46 changes: 5 additions & 41 deletions src/main/resources/application-stag.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
spring:
application:
name: auth
config:
import: "optional:configserver:http://localhost:9000"
cloud:
config:
fail-fast: true

datasource:
url: jdbc:postgresql://cnpg-cluster-rw.database.svc.cluster.local:5432/auth
username: auth
password: auth
flyway:
locations: classpath:db/migration
r2dbc:
url: r2dbc:postgresql://cnpg-cluster-rw.database.svc.cluster.local:5432/auth
username: auth
password: auth

jwt:
rsa-key-path: "rsaKey.json"

########################
# DevOps
########################
# Actuator, Prometheus, OpenTelemetry
management:
endpoints:
info:
enabled: true
web:
exposure:
include: health, info, prometheus, metrics
metrics:
enabled: true
export:
prometheus:
enabled: true
prometheus:
enabled: true
tracing:
sampling:
probability: 1.0
zipkin:
tracing:
endpoint: http://otel-collector-opentelemetry-collector.tracing:9411/api/v2/spans
logging:
pattern:
level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
21 changes: 0 additions & 21 deletions src/main/resources/application.yml

This file was deleted.

9 changes: 9 additions & 0 deletions src/main/resources/bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spring:
application:
name: auth
cloud:
config:
uri: https://localhost:9000
fail-fast: true
profiles:
active: local
5 changes: 4 additions & 1 deletion src/test/kotlin/com/api/auth/JwtTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import com.api.auth.service.AuthService
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.data.annotation.AccessType
import org.springframework.test.context.ActiveProfiles
import java.time.Instant
import java.time.temporal.ChronoUnit

@SpringBootTest
@ActiveProfiles("local")
class JwtTest(
@Autowired private val rsaKeyBuilder: RsaKeyBuilder,
@Autowired private val jwtBuilder: JwtBuilder,
Expand All @@ -35,7 +38,7 @@ class JwtTest(
@Test
fun createToken1() {
val request = JwtRequest(
address = "qweqwascfsadadfasd"
address = "test12345123"
)
authService.createToken(request).block()
}
Expand Down

0 comments on commit c088626

Please sign in to comment.