Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔀 :: 258 add exporter dependency #259

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading