feat: zitadel provisioning script + project-audience scope

This commit is contained in:
2026-06-10 08:07:20 +00:00
parent f83bb25316
commit 56186a1fea
4 changed files with 178 additions and 0 deletions

View File

@@ -5,9 +5,15 @@ import { useZitadelAuth } from "@kuns/zitadel-auth/vue";
// router guard that redirects unauthenticated users to the Zitadel hosted login.
export default defineNuxtPlugin(() => {
const cfg = useRuntimeConfig().public;
const scopes = ["openid", "profile", "email"];
if (cfg.zitadelProjectId) {
// Force the project id into the access token's `aud` for backend validation.
scopes.push(`urn:zitadel:iam:org:project:id:${cfg.zitadelProjectId}:aud`);
}
const auth = useZitadelAuth(useRouter() as never, {
clientId: cfg.zitadelClientId as string,
issuer: cfg.zitadelIssuer as string,
scopes,
});
return { provide: { auth } };
});