close

Filter

Elastic Social Manual / Version 2404

Table Of Contents

4.7.2 Multi-Tenancy

Elastic Core supports multi-tenancy. A tenant can have many sites, but each site belongs to exactly one tenant. In a multi-tenancy environment a TenantForSiteStrategy is used to determine the tenant for a given site. CoreMedia Blueprint contains a solution based on settings. For each call to the Elastic Core API a tenant has to be defined or an exception will be raised. If only one tenant is required, you can define a default tenant using the property tenant.default. Tenants have to be registered at the TenantService and may then be set and cleared for each thread. It is recommended to set the tenant as early in a request cycle as possible. Elastic Core includes a servlet filter that uses a TenantLookupStrategy to determine the tenant for a request. A TenantLookupStrategy is only required in a multi-tenancy setup. Elastic Social comes with an implementation for Studio REST calls and Blueprint defines a strategy for CAE applications as well. If you have your own project application, you need to define the Servlet Filter that comes with Elastic Social and implement your own TenantLookupStrategy.

The default tenant can only be statically configured and is used at runtime for every thread that otherwise has no tenant. The default tenant cannot be deregistered but its tenant scope is destroyed when the application context is closed so that destruction callbacks are invoked.

The TenantFilter needs to be configured as FilterRegistrationBean, see ESCaeFilters for details.

@Configuration(proxyBeanMethods = false)
public class EsCaeFilters {
  @Bean
  public FilterRegistrationBean tenantFilterRegistration(Filter tenantFilter) {
    return RegistrationBeanBuilder
            .forFilter(tenantFilter)
            .urlPatterns("/servlet/*")
            .order(120)
            .build();
  }
}

          

Example 4.18. Configure a tenant filter and its mapping in your own application context


Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.