feat(login): add LOGIN_SERVICE_KEY_FILE authentication support (#11572)

This commit is contained in:
Mridang Agarwalla
2026-02-24 10:14:24 +00:00
committed by GitHub
parent 839a2d3b5b
commit 54095b64b1
5 changed files with 133 additions and 5 deletions
+6 -4
View File
@@ -6,8 +6,8 @@ import { SAMLService } from "@zitadel/proto/zitadel/saml/v2/saml_service_pb";
import { SessionService } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
import { SettingsService } from "@zitadel/proto/zitadel/settings/v2/settings_service_pb";
import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
import { systemAPIToken } from "./api";
import { hasSystemUserCredentials, hasServiceUserToken } from "./deployment";
import { systemAPIToken, loginServiceKeyToken } from "./api";
import { hasSystemUserCredentials, hasLoginServiceKey, hasServiceUserToken } from "./deployment";
import { createServerTransport, ServiceConfig } from "./zitadel";
type ServiceClass =
@@ -23,15 +23,17 @@ export async function createServiceForHost<T extends ServiceClass>(service: T, s
let token;
// Determine authentication method based on available credentials
// Prefer system user JWT if available, fallback to service account token
// Priority: system user JWT > login service key > service account token
if (hasSystemUserCredentials()) {
token = await systemAPIToken();
} else if (hasLoginServiceKey()) {
token = await loginServiceKeyToken();
} else if (hasServiceUserToken()) {
// Use service account token authentication (self-hosted)
token = process.env.ZITADEL_SERVICE_USER_TOKEN;
} else {
throw new Error(
"No authentication credentials found. Set either system user credentials (AUDIENCE, SYSTEM_USER_ID, SYSTEM_USER_PRIVATE_KEY) or ZITADEL_SERVICE_USER_TOKEN",
"No authentication credentials found. Set either system user credentials (AUDIENCE, SYSTEM_USER_ID, SYSTEM_USER_PRIVATE_KEY), login service key (ZITADEL_LOGIN_SERVICE_KEY_FILE with ZITADEL_LOGIN_SYSTEM_USER_ID or SYSTEM_USER_ID), or ZITADEL_SERVICE_USER_TOKEN",
);
}