Demand origin
This section achieve dynamic URL rights by extending access () SpEL of expression.
Coding ideas
By extending SpEL expression primarily in specific configuration and implementation of class methods, the following example
.access("@authService.canAccess(request,authentication)");
Wherein authService is a class, canAccess in which method:
@Component
public class AuthService {
public boolean canAccess(HttpServletRequest request, Authentication authentication) {
//在这里编写校验代码…
return true;
}
}
First, the expansion of access () expression of SpEL