Приведенный ниже фрагмент кода работает для исключения аутентификации для конкретной конечной точки.
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true)
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
private static final String[] excludeEndPoint = { "/getEmployees" };
private HttpSecurity unifiedConfiguration(HttpSecurity http) throws Exception {
return http
.authorizeRequests()
.antMatchers(HttpMethod.GET, excludeEndPoint).permitAll()
.anyRequest().authenticated();
}
}
Но я хочу удалить эту логику из класса SpringSecurityConfig и добавить некоторую настраиваемую аннотацию (например, UnauthenticateURL) на уровне метода.
Spring Boot API Example :
@GetMapping(path = "/getEmployees")
@UnauthenticateURL
public List<Employee> getEmployeeList() throws Exception {
........
........
Buisiness logic
........
}
Custom Annotation :
@Target({ METHOD})
@Retention(RUNTIME)
public @interface UnauthenticateURL {
}
Возможно ли реализовать эту логику с помощью Spring Security с приложением Spring Boot?