Interface MenuAccessControl

All Superinterfaces:
Serializable
All Known Implementing Classes:
DefaultMenuAccessControl, SpringMenuAccessControl

public interface MenuAccessControl extends Serializable
Interface for controlling access to routes in the application's menu component.
  • Method Details

    • setPopulateClientSideMenu

      void setPopulateClientSideMenu(MenuAccessControl.PopulateClientMenu populateClientSideMenu)
      Sets whether the Hilla application's main menu should be populated automatically with server side routes and therefore routes information sent to the browser. Three possible values: MenuAccessControl.PopulateClientMenu.ALWAYS, MenuAccessControl.PopulateClientMenu.NEVER, MenuAccessControl.PopulateClientMenu.AUTOMATIC.
      Parameters:
      populateClientSideMenu - whether the client-side menu should be populated with server side routes
    • getPopulateClientSideMenu

      MenuAccessControl.PopulateClientMenu getPopulateClientSideMenu()
      Gets whether the Hilla application's main menu should be populated automatically with server side routes and therefore routes information sent to the browser.
      Returns:
      enum of type MenuAccessControl.PopulateClientMenu
    • canAccessView

      default boolean canAccessView(AvailableViewInfo viewInfo)
      Determines if current user has permissions to access the given view.

      It checks view against authentication state: - If view does not require login -> allow - If not authenticated and login required -> deny. - If user doesn't have correct roles -> deny.
      Parameters:
      viewInfo - view info
      Returns:
      true if the view is accessible, false if something is not authenticated.
    • canAccessView

      static boolean canAccessView(AvailableViewInfo viewInfo, Principal principal, Predicate<String> roleChecker)
      Check view against authentication state.

      If not authenticated and login required -> invalid. If user doesn't have correct roles -> invalid.

      Parameters:
      viewInfo - view info
      principal - current user, can be null
      roleChecker - function to authenticate if user has role
      Returns:
      true if accessible, false if something is not authenticated