mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-01 16:38:52 +00:00
feat(login): add LOGIN_SERVICE_KEY_FILE authentication support (#11572)
This commit is contained in:
@@ -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",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user