@@ -0,0 +1,1309 @@
+package com.konkerlabs.platform.registry.security;%0A%0Aimport com.konkerlabs.platform.registry.business.model.Application;%0Aimport com.konkerlabs.platform.registry.business.model.Tenant;%0Aimport com.konkerlabs.platform.registry.business.model.User;%0Aimport org.springframework.beans.factory.SmartFactoryBean;%0Aimport org.springframework.security.core.context.SecurityContextHolder;%0Aimport org.springframework.security.core.userdetails.UserDetails;%0Aimport org.springframework.stereotype.Component;%0A%0A@Component(%22application%22)%0Apublic class ApplicationContextResolver implements SmartFactoryBean%3CApplication%3E %7B%0A%0A    @Override%0A    public Application getObject() throws Exception %7B%0A        UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();%0A        Tenant tenant =  User.class.cast(userDetails).getTenant();%0A        // Return tenant default application%0A        return Application.builder().name(tenant.getDomainName()).build();%0A    %7D%0A%0A    @Override%0A    public Class%3C?%3E getObjectType() %7B%0A        return Application.class;%0A    %7D%0A%0A    @Override%0A    public boolean isSingleton() %7B%0A        return false;%0A    %7D%0A%0A    @Override%0A    public boolean isPrototype() %7B%0A        return true;%0A    %7D%0A%0A    @Override%0A    public boolean isEagerInit() %7B%0A        return false;%0A    %7D%0A%7D%0A

Add ApplicationContextResolver