Spring Boot Admin 集成
parent
d9d073bcd6
commit
d3b643c363
@ -0,0 +1,30 @@
|
|||||||
|
package com.example.venue_reservation_service.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
public class SecurityConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
|
http
|
||||||
|
.authorizeHttpRequests(auth -> auth
|
||||||
|
// 所有请求都无需认证
|
||||||
|
.anyRequest().permitAll()
|
||||||
|
)
|
||||||
|
.formLogin(AbstractHttpConfigurer::disable // 禁用表单登录
|
||||||
|
)
|
||||||
|
.httpBasic(AbstractHttpConfigurer::disable // 禁用 HTTP Basic
|
||||||
|
)
|
||||||
|
.csrf(AbstractHttpConfigurer::disable // 开发环境建议禁用 CSRF
|
||||||
|
);
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue