Skip to content
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: 5 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ repositories {
}

dependencies {
/* SPRING BOOT STARTER */
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

/* DATABASE */
runtimeOnly 'com.mysql:mysql-connector-j'

/* MONITORING */
implementation 'io.micrometer:micrometer-registry-prometheus'

/* TEST */
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import lombok.RequiredArgsConstructor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
Expand All @@ -32,6 +33,9 @@ public class SecurityConfig {
private final AdminLoginSuccessHandler adminLoginSuccessHandler;
private final AdminLoginFailureHandler adminLoginFailureHandler;

@Value("${management.endpoints.web.base-path:/actuator}")
private String actuatorBasePath;

@Bean
public SecurityFilterChain userFilterChain(HttpSecurity http) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
Expand Down Expand Up @@ -66,6 +70,8 @@ public SecurityFilterChain userFilterChain(HttpSecurity http) throws Exception {
.hasAnyRole("USER", "ADMIN")
.requestMatchers("/questions/**")
.hasAnyRole("USER", "ADMIN")
.requestMatchers(actuatorBasePath + "/**")
.hasRole("PROMETHEUS")
.anyRequest()
.authenticated())
.formLogin(
Expand Down
22 changes: 22 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,26 @@ server:
secure: true
http-only: true
timeout: ${SESSION_TIMEOUT}
---
spring:
config:
activate:
on-profile: prod

security:
user:
name: ${PROM_NAME}
password: ${PROM_PASSWORD}
roles: PROMETHEUS

management:
server:
port: ${ACTUATOR_PORT}
endpoints:
web:
exposure:
include: "prometheus"
base-path: ${ACTUATOR_BASE_PATH}
endpoint:
prometheus:
access: read_only