Skip to content

Commit

Permalink
Merge pull request #259 from GSM-MSG/258-feat/add-exporter-dependency
Browse files Browse the repository at this point in the history
🔀 :: 258 add exporter dependency
  • Loading branch information
KimTaeO authored Feb 2, 2024
2 parents 10c1d11 + 1a73074 commit aa6d772
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
testImplementation(Dependencies.SPRING_STARTER_TEST)
testImplementation(Dependencies.SPRING_SECURITY_TEST)
implementation(Dependencies.SPRING_AOP)

implementation(Dependencies.SPRING_ACTUATOR)

// kotlin
implementation(Dependencies.JACKSON_MODULE_KOTLIN)
Expand Down Expand Up @@ -73,6 +73,9 @@ dependencies {
implementation(Dependencies.QUERY_DSL)
implementation(Dependencies.QUERY_DSL_APT)
kapt(Dependencies.QUERY_DSL_APT)

// prometheus
implementation(Dependencies.PROMETHEUS_MICROMETER)
}


Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ object Dependencies {
const val SPRING_STARTER_TEST = "org.springframework.boot:spring-boot-starter-test"
const val SPRING_SECURITY_TEST = "org.springframework.security:spring-security-test"
const val SPRING_AOP = "org.springframework.boot:spring-boot-starter-aop"
const val SPRING_ACTUATOR = "org.springframework.boot:spring-boot-starter-actuator"

// jackson
const val JACKSON_MODULE_KOTLIN = "com.fasterxml.jackson.module:jackson-module-kotlin"
Expand Down Expand Up @@ -43,4 +44,6 @@ object Dependencies {
const val QUERY_DSL = "com.querydsl:querydsl-jpa:${DependencyVersions.QUERY_DSL_VERSION}"
const val QUERY_DSL_APT = "com.querydsl:querydsl-apt:${DependencyVersions.QUERY_DSL_APT_VERSION}:jpa"

// prometheus
const val PROMETHEUS_MICROMETER = "io.micrometer:micrometer-registry-prometheus"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.msg.gauth.global.security.config.FilterConfig
import com.msg.gauth.global.security.jwt.JwtTokenProvider
import com.msg.gauth.global.security.jwt.TokenParser
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
import org.springframework.boot.actuate.autoconfigure.security.servlet.SecurityRequestMatchersManagementContextConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpMethod
import org.springframework.security.config.Customizer.withDefaults
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
Expand All @@ -15,6 +18,7 @@ import org.springframework.security.web.SecurityFilterChain
import org.springframework.security.web.util.matcher.RequestMatcher
import org.springframework.web.cors.CorsUtils


@Configuration
class SecurityConfig(
private val jwtTokenProvider: JwtTokenProvider,
Expand Down Expand Up @@ -88,6 +92,11 @@ class SecurityConfig(
.antMatchers(HttpMethod.POST, "/image").authenticated()
.antMatchers(HttpMethod.DELETE, "/image").authenticated()

// Actuator
.antMatchers(HttpMethod.GET, "/actuator/health").hasRole("ADMIN")
.antMatchers(HttpMethod.GET, "/actuator/info").hasRole("ADMIN")
.antMatchers(HttpMethod.GET, "/actuator/prometheus").hasRole("ADMIN")

.anyRequest().denyAll()
.and()
.exceptionHandling()
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,20 @@ jwt:
accessSecret: ${JWT_ACCESS}
refreshSecret: ${JWT_REFRESH}
oauthSecret: ${JWT_OAUTH}

management:
endpoints:
enabled-by-default: false
web:
exposure:
include: health,info,prometheus

endpoint:
health:
enabled: true

info:
enabled: true

prometheus:
enabled: true

0 comments on commit aa6d772

Please sign in to comment.