tenants: initial implementation

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-05-29 17:35:56 +02:00
parent a1b6e09e8a
commit ff611f21cd
21 changed files with 843 additions and 59 deletions

View File

@ -1,4 +1,4 @@
import { Config, Configuration, Middleware, ResponseContext, RootApi } from "authentik-api";
import { Config, Configuration, CoreApi, CurrentTenant, Middleware, ResponseContext, RootApi, Tenant } from "authentik-api";
import { getCookie } from "../utils";
import { API_DRAWER_MIDDLEWARE } from "../elements/notifications/APIDrawer";
import { MessageMiddleware } from "../elements/messages/Middleware";
@ -20,6 +20,14 @@ export function config(): Promise<Config> {
return globalConfigPromise;
}
let globalTenantPromise: Promise<CurrentTenant>;
export function tenant(): Promise<CurrentTenant> {
if (!globalTenantPromise) {
globalTenantPromise = new CoreApi(DEFAULT_CONFIG).coreTenantsCurrentRetrieve();
}
return globalTenantPromise;
}
export const DEFAULT_CONFIG = new Configuration({
basePath: "",
headers: {