public class CustomAccessDeniedError extends RouteAccessDeniedError {
@Override
public int setErrorParameter(BeforeEnterEvent event, ErrorParameter<AccessDeniedException> parameter) {
event.forwardTo(AccessDeniedView.class);
return HttpServletResponse.SC_FORBIDDEN;
}
}
However, this does not.
public class CustomNotFoundError extends RouteNotFoundError {
@Override
public int setErrorParameter(BeforeEnterEvent event, ErrorParameter<NotFoundException> parameter) {
event.forwardTo(NotFoundView.class);
return HttpServletResponse.SC_NOT_FOUND;
}
}
Instead of the custom NotFoundView, I get a 403 on the browser.
What am I missing?
I am struggling with spring security configuration. In Vaadin 25 I did not manage to configure spring security so, that unknown routes are not blocked automatically on spring security level.
This configuration blocks every unknown route, no custom vaadin error:
In Vaadin 25, the default is to forbid access to any request, regardless of whether it matches a route or not.
You can tune the rule by using the VaadinSecurityConfigurator.anyRequest(...) method or disable Vaadin’s config with VaadinSecurityConfigurator.enableAuthorizedRequestsConfiguration(false) and set your own default rule (e.g., authenticated()).
Thank you! I did find the part. Maybe the documentation should be more clear. I know that it is now spring security default to deny all, but all the documentation about Router Exception Handling and in particular NotFoundException does not apply if spring security blocks any by default. Thanks again for pointing to the right direction!