Fix spring security config
This commit is contained in:
parent
f0c683cd39
commit
d7d05132c8
@ -17,18 +17,24 @@ import ru.ulstu.model.UserRoleConstants;
|
|||||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||||
public class SecurityConfiguration {
|
public class SecurityConfiguration {
|
||||||
private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class);
|
private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class);
|
||||||
|
private final String[] permittedUrls = new String[]{
|
||||||
|
"/login", "/index", "/news/**",
|
||||||
|
"/meetings/**", "/files/**", "/docs/**",
|
||||||
|
"/public/**", "/organizers", "/webjars/**",
|
||||||
|
"/h2-console/*", "/h2-console",
|
||||||
|
"/css/**", "/js/**", "/img/**",
|
||||||
|
"/templates/**", "/webjars/**"};
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
log.debug("Security enabled");
|
log.debug("Security enabled");
|
||||||
|
|
||||||
http
|
http
|
||||||
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.authorizeHttpRequests(auth ->
|
.authorizeHttpRequests(auth ->
|
||||||
auth.requestMatchers("/").permitAll()
|
auth.requestMatchers("/").permitAll()
|
||||||
.requestMatchers("/login", "/index", "/news/**", "/meetings/**", "/files/**", "/docs/**",
|
.requestMatchers(permittedUrls).permitAll()
|
||||||
"/public/**", "/organizers", "/webjars/**", "/h2-console/*", "/h2-console",
|
|
||||||
"/css/**", "/js/**", "/img/**", "/templates/**", "/webjars/**").permitAll()
|
|
||||||
.requestMatchers("/swagger-ui.html").hasAuthority(UserRoleConstants.ADMIN)
|
.requestMatchers("/swagger-ui.html").hasAuthority(UserRoleConstants.ADMIN)
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
.formLogin(form ->
|
.formLogin(form ->
|
||||||
|
Loading…
Reference in New Issue
Block a user