Class MultiTenancyValidator

java.lang.Object
io.camunda.zeebe.gateway.rest.validator.MultiTenancyValidator

public final class MultiTenancyValidator extends Object
  • Constructor Details

    • MultiTenancyValidator

      public MultiTenancyValidator()
  • Method Details

    • validateAuthorization

      public static Optional<org.springframework.http.ProblemDetail> validateAuthorization(String tenantId, boolean multiTenancyEnabled, String commandName)
      Validates whether a tenant is authorized to perform the request. It does so by checking the provided tenant against the list of authorized tenant in the authentication context.
      Parameters:
      tenantId - the tenant to check if it's authorized
      multiTenancyEnabled - whether multi-tenancy is enabled
      commandName - the name of the command, used for error messages
      Returns:
      a optional ProblemDetail if the tenant is not authorized
    • validateTenantId

      public static Either<org.springframework.http.ProblemDetail,String> validateTenantId(String tenantId, boolean multiTenancyEnabled, String commandName)
      Validates the tenantId. If multi-tenancy is disabled, the tenantId must be empty, or the default tenant. if multi-tenancy is enabled a tenantId must be provided and should match the tenantId mask.

      If all validations succeed the method returns the tenantId that should be used in the request. This must always be set in the request, as there is no guarantee that the client provided a tenantId.

      Parameters:
      tenantId - the tenantId to validate
      multiTenancyEnabled - whether multi-tenancy is enabled
      commandName - the name of the command, used for error messages
      Returns:
      a Either containing a ProblemDetail if the tenantId is invalid, or the tenantId if it's valid