Adjust health response and auth chain ordering
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s

This commit is contained in:
androidlover5842
2026-01-26 21:25:17 +05:30
parent 05b8fd409c
commit 398ad93232
2 changed files with 17 additions and 4 deletions

View File

@@ -7,11 +7,11 @@ import org.springframework.web.bind.annotation.RestController
class Health { class Health {
@GetMapping("/health") @GetMapping("/health")
fun health(): Map<String, String> { fun health(): Map<String, String> {
return mapOf("status" to "ok Testing Health..") return mapOf("status" to "ok", "build" to "2026-01-26-authfix")
} }
@GetMapping("/") @GetMapping("/")
fun root(): Map<String, String> { fun root(): Map<String, String> {
return mapOf("status" to "Hello World!") return mapOf("status" to "ok", "build" to "2026-01-26-authfix")
} }
} }

View File

@@ -2,6 +2,7 @@ package com.android.trisolarisserver.security
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import org.springframework.core.annotation.Order
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity
import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.config.http.SessionCreationPolicy
@@ -14,12 +15,24 @@ class SecurityConfig(
private val firebaseAuthFilter: FirebaseAuthFilter private val firebaseAuthFilter: FirebaseAuthFilter
) { ) {
@Bean @Bean
fun filterChain(http: HttpSecurity): SecurityFilterChain { @Order(0)
fun authChain(http: HttpSecurity): SecurityFilterChain {
http
.securityMatcher("/auth/**", "/", "/health")
.csrf { it.disable() }
.authorizeHttpRequests { it.anyRequest().permitAll() }
.httpBasic { it.disable() }
.formLogin { it.disable() }
return http.build()
}
@Bean
@Order(1)
fun apiChain(http: HttpSecurity): SecurityFilterChain {
http http
.csrf { it.disable() } .csrf { it.disable() }
.sessionManagement { it.sessionCreationPolicy(SessionCreationPolicy.STATELESS) } .sessionManagement { it.sessionCreationPolicy(SessionCreationPolicy.STATELESS) }
.authorizeHttpRequests { .authorizeHttpRequests {
it.requestMatchers("/", "/health", "/auth/**").permitAll()
it.anyRequest().authenticated() it.anyRequest().authenticated()
} }
.httpBasic { it.disable() } .httpBasic { it.disable() }