У меня есть что-то вроде
Код: Выделить всё
http.authorizeRequests()
.mvcMatchers("/")
.hasIpAddress("127.0.0.1")
Код: Выделить всё
http.authorizeHttpRequests()
.mvcMatchers("/")
.access("hasIpAddress('127.0.0.1')")
Код: Выделить всё
@Bean
SecurityFilterChain web(HttpSecurity http) throws Exception {
http
// ...
.authorizeHttpRequests(authorize -> authorize
.mvcMatchers("/resources/**", "/signup", "/about").permitAll()
.mvcMatchers("/admin/**").hasRole("ADMIN")
.mvcMatchers("/db/**").access("hasRole('ADMIN') and hasRole('DBA')")
.anyRequest().denyAll()
);
return http.build();
}
Вот ошибка компиляции:
Код: Выделить всё
Application.java:103:55
java: incompatible types: java.lang.String cannot be converted to org.springframework.security.authorization.AuthorizationManager
Я использую Spring Boot 2.7.0 и Spring Security 5.7.1
Подробнее здесь: https://stackoverflow.com/questions/723 ... tprequests
Мобильная версия