Guarded screens

With this package, @PreAuthorize on a screen of spring_boot_starter_flutter_navigation (which it brings) takes the expressions of method security. Nobody logged in goes to spring.flutter.navigation.login, and back to the screen after the login, however it happens. A logged-in user without the right gets the error screen.

Why

Which screens a user may open is one rule, wherever the navigation comes from: a tap, the browser's address bar, a deep link. The routeSecurity bean checks it for every navigation, with the application's MethodSecurityExpressionHandler, so the role hierarchy and custom expressions apply as on beans.

Example

@ScreenRoute('/admin', title: 'Admin')
@PreAuthorize("hasRole('ADMIN')")
class AdminPage extends StatelessWidget { ... }

@ScreenRoute('/login', title: 'Log in')
class LoginPage extends StatelessWidget {
  const LoginPage({super.key});

  // After the login, the navigation returns to the guarded screen by itself.
  @override
  Widget build(BuildContext context) => const LoginForm();
}
spring:
  flutter:
    navigation:
      login: /login

The rules

A guard hides screens on the device; the server still checks every request.

See also