Dynamic access-control policies evaluate authorization rules at runtime rather than relying on static role checks, typically using Spring Expression Language inside @PreAuthorize or @PostAuthorize to reference live data such as method arguments, the current user, or database-backed permissions.
A document-sharing app uses @PreAuthorize("@docPermissionEvaluator.canEdit(#docId, authentication)") to check, at runtime, whether the current user has been granted edit rights on that specific document by looking it up in the database.
@PreAuthorize("@docPermissionEvaluator.canEdit(#docId, authentication)")
public void editDocument(Long docId, String content) {
// edit logic
}A concise interview answer is
I'd use SpEL inside @PreAuthorize or @PostAuthorize to evaluate access rules at runtime, referencing method parameters or a custom PermissionEvaluator bean that checks permissions dynamically, often against a database. This supports attribute- or resource-based access control beyond simple static roles.
Last updated: 16 July 2026
Next question: How do you test security configurations in Spring applications?