Hi,
I’m currently testing Vaadin in combination with Spring Boot and Spring Security. I’ve been following the docs so far, but stumbled upon an issue with configuring the NavigationAccessControlConfigurer:
@Configuration
@EnableWebSecurity
@Import(VaadinAwareSecurityContextHolderStrategyConfiguration.class)
public class WebSecurityConfiguration {
@Bean
static NavigationAccessControlConfigurer navigationAccessControlConfigurer() {
return new NavigationAccessControlConfigurer()
.withRoutePathAccessChecker()
.withNavigationAccessChecker(new MyCustomNavigationAccessChecker());
}
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http, RouteUtil routeUtil) throws Exception {
return http.authorizeHttpRequests(registry -> {
registry.requestMatchers(routeUtil::isRouteAllowed).permitAll();
}).with(VaadinSecurityConfigurer.vaadin(), vaadin -> {
}).build();
}
@Bean
public UserDetailsManager userDetailsManager() {
return new InMemoryUserDetailsManager(...);
}
}
The MyCustomNavigationAccessChecker does not contain any logic whatsoever:
@Override
public AccessCheckResult check(NavigationContext context) {
LOGGER.info("check access for {}", context);
if (context.isErrorHandling()) {
return AccessCheckResult.neutral();
}
return AccessCheckResult.allow();
}
Using the custom checker, accessing the webserver fails with an exception:
2025-09-17T21:18:05.589+02:00 ERROR 12220 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
java.lang.UnsupportedOperationException: public abstract java.security.Principal jakarta.servlet.http.HttpServletRequest.getUserPrincipal() is not supported
at org.springframework.security.web.FilterInvocation$UnsupportedOperationExceptionInvocationHandler.invoke(FilterInvocation.java:331) ~[spring-security-web-6.5.3.jar:6.5.3]
at jdk.proxy2/jdk.proxy2.$Proxy177.getUserPrincipal(Unknown Source) ~[na:na]
at jakarta.servlet.http.HttpServletRequestWrapper.getUserPrincipal(HttpServletRequestWrapper.java:181) ~[tomcat-embed-core-10.1.44.jar:6.0]
at jakarta.servlet.http.HttpServletRequestWrapper.getUserPrincipal(HttpServletRequestWrapper.java:181) ~[tomcat-embed-core-10.1.44.jar:6.0]
at com.vaadin.hilla.route.RouteUtil.filterClientViews(RouteUtil.java:79) ~[hilla-endpoint-24.9.0.jar:na]
at com.vaadin.hilla.route.RouteUtil.getRouteData(RouteUtil.java:145) ~[hilla-endpoint-24.9.0.jar:na]
at com.vaadin.hilla.route.RouteUtil.isRouteAllowed(RouteUtil.java:71) ~[hilla-endpoint-24.9.0.jar:na]
at org.springframework.security.web.util.matcher.RequestMatcher.matcher(RequestMatcher.java:48) ~[spring-security-web-6.5.3.jar:6.5.3]
As soon as I remove the .withNavigationAccessChecker(...) I can load pages again.
Is this something I did wrong and just couldn’t find in the docs?