3232import com .vaadin .flow .router .RouterLayout ;
3333import com .vaadin .flow .router .internal .RouteUtil ;
3434import com .vaadin .flow .server .RouteRegistry ;
35+ import com .vaadin .flow .server .VaadinContext ;
36+ import com .vaadin .flow .server .startup .ApplicationConfiguration ;
3537
3638/**
3739 * Checks access to views using an {@link AccessAnnotationChecker}.
@@ -163,12 +165,16 @@ private void logDeniedByLayoutAccessRules(NavigationContext context,
163165
164166 private void logDeniedByLayoutAccessRules (NavigationContext context ,
165167 Class <?> layoutClass , String msg ) {
166- if (context .isNavigating ()) {
167- LOGGER .warn (msg , context .getNavigationTarget ().getSimpleName (),
168- layoutClass .getSimpleName ());
168+ if (context .isNavigating () || isDevelopmentMode (context )) {
169+ if (!context .isNavigating ()) {
170+ msg = msg
171+ + " This access check was probably triggered by the security framework." ;
172+ }
173+ LOGGER .warn (msg , context .getNavigationTarget ().getName (),
174+ layoutClass .getName ());
169175 } else {
170- LOGGER .trace (msg , context .getNavigationTarget ().getSimpleName (),
171- layoutClass .getSimpleName ());
176+ LOGGER .debug (msg , context .getNavigationTarget ().getName (),
177+ layoutClass .getName ());
172178 }
173179 }
174180
@@ -178,4 +184,11 @@ private boolean isImplicitlyDenyAllAnnotated(Class<?> targetView) {
178184 || targetView .isAnnotationPresent (RolesAllowed .class ));
179185 }
180186
187+ private boolean isDevelopmentMode (NavigationContext context ) {
188+ VaadinContext vaadinContext = context .getRouter ().getRegistry ()
189+ .getContext ();
190+ ApplicationConfiguration appConfig = ApplicationConfiguration
191+ .get (vaadinContext );
192+ return !appConfig .isProductionMode ();
193+ }
181194}
0 commit comments