35 行
1.5 KiB
Java
35 行
1.5 KiB
Java
|
|
package com.xuqm.update.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.config.http.SessionCreationPolicy;
|
||
|
|
import org.springframework.security.web.SecurityFilterChain;
|
||
|
|
|
||
|
|
@Configuration
|
||
|
|
@EnableWebSecurity
|
||
|
|
public class SecurityConfig {
|
||
|
|
|
||
|
|
@Bean
|
||
|
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||
|
|
http
|
||
|
|
.csrf(AbstractHttpConfigurer::disable)
|
||
|
|
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||
|
|
.authorizeHttpRequests(auth -> auth
|
||
|
|
.requestMatchers(
|
||
|
|
"/actuator/**",
|
||
|
|
"/api/v1/updates/app/check",
|
||
|
|
"/api/v1/rn/update/check",
|
||
|
|
"/api/v1/rn/files/**",
|
||
|
|
"/files/apk/**"
|
||
|
|
).permitAll()
|
||
|
|
.anyRequest().authenticated()
|
||
|
|
)
|
||
|
|
.httpBasic(AbstractHttpConfigurer::disable)
|
||
|
|
.formLogin(AbstractHttpConfigurer::disable);
|
||
|
|
return http.build();
|
||
|
|
}
|
||
|
|
}
|