1. Domino Brix
  2. Security

Authorization

Presenters implement HasRoles and HasAuthorizer so Brix can check access before activation. Built-in authorizers include DefaultAuthorizer, PermitAllAuthorizer, DenyAllAuthorizer, and RolesAllowedAuthorizer.

			@BrixPresenter
public class AdminPresenter extends Presenter<AdminView> {
  @Override
  public Set<String> getRoles() {
    return Set.of("admin");
  }

  @Override
  public Authorizer getAuthorizer() {
    return RolesAllowedAuthorizer.INSTANCE;
  }
}

		

Annotation-based security

Use @PermitAll, @DenyAll, or @RolesAllowed on a presenter to have the processor generate getAuthorizer() (and getRoles() for @RolesAllowed). Only one of these annotations is allowed per presenter.

			@BrixPresenter
@RolesAllowed({"admin", "support"})
public class AdminPresenter extends Presenter<AdminView> {
  // getAuthorizer() and getRoles() are generated by the processor
}

		

Security context

Use SecurityContext to set the active user, check authentication, and handle unauthorized access.

			SecurityContext sc = (SecurityContext) Brix.get().getCoreComponent().core().getSecurityContext();
sc.setUser(new MyUser());
sc.setUnauthorizedAccessHandler(() -> window.alert("Access denied"));

		

Custom authorizers

Implement Authorizer for domain-specific checks and return it from your presenter.

			public class DepartmentAuthorizer implements Authorizer {
  @Override
  public boolean isAuthorized(IsSecurityContext context, HasRoles hasRoles) {
    return context.isAuthenticated()
        && context.getUser().getAttributes().get("department").ifTypeIs(String.class, dept -> {
             return dept.equals("engineering");
           });
  }
}

		

We are a group of passionate people who love what we do

Donate & Support Us