Class MultiTenancyValidator
java.lang.Object
io.camunda.zeebe.gateway.rest.validator.MultiTenancyValidator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<org.springframework.http.ProblemDetail> validateAuthorization(String tenantId, boolean multiTenancyEnabled, String commandName) Validates whether a tenant is authorized to perform the request.validateTenantId(String tenantId, boolean multiTenancyEnabled, String commandName) Validates the tenantId.
-
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 authorizedmultiTenancyEnabled- whether multi-tenancy is enabledcommandName- the name of the command, used for error messages- Returns:
- a optional
ProblemDetailif 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 validatemultiTenancyEnabled- whether multi-tenancy is enabledcommandName- the name of the command, used for error messages- Returns:
- a
Eithercontaining aProblemDetailif the tenantId is invalid, or the tenantId if it's valid
-