У меня есть следующий класс:
Код: Выделить всё
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
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;
import java.util.List;
@Configuration
@EnableWebSecurity
public class ResourceServerConfig {
private final List protectedPaths = List.of(
"/my-profile",
"/my-notes",
"/etc"
);
@Bean
@Order(2)
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.securityMatchers(customizer -> customizer.requestMatchers(protectedPaths.toArray(new String[0])))
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(requests -> requests.anyRequest().authenticated())
.oauth2ResourceServer(server -> server.jwt(
customizer -> customizer.jwtAuthenticationConverter(new UserAuthenticationTokenConverter())
));
return http.build();
}
}
Как установить заголовки Cache-Control в protectedPaths?
Подробнее здесь: https://stackoverflow.com/questions/798 ... pplication
Мобильная версия