mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-24 05:38:46 +00:00
feat(login): simplify login client auth and support PKCS#1 keys (#11888)
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 { loginServiceKeyToken, systemAPIToken } from "./api";
|
||||
import { hasLoginServiceKey, hasServiceUserToken, hasSystemUserCredentials } from "./deployment";
|
||||
import { loginClientKeyToken, systemAPIToken } from "./api";
|
||||
import { hasLoginClientKey, hasServiceUserToken, hasSystemUserCredentials } from "./deployment";
|
||||
import { createServerTransport, ServiceConfig } from "./zitadel";
|
||||
|
||||
type ServiceClass =
|
||||
@@ -23,17 +23,17 @@ export async function createServiceForHost<T extends ServiceClass>(service: T, s
|
||||
let token;
|
||||
|
||||
// Determine authentication method based on available credentials
|
||||
// Priority: system user JWT > login service key > service account token
|
||||
// Priority: system user JWT > login client key > service account token
|
||||
if (hasSystemUserCredentials()) {
|
||||
token = await systemAPIToken();
|
||||
} else if (hasLoginServiceKey()) {
|
||||
token = await loginServiceKeyToken();
|
||||
} else if (hasLoginClientKey()) {
|
||||
token = await loginClientKeyToken();
|
||||
} 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), login service key (ZITADEL_LOGIN_SERVICE_KEY_FILE with ZITADEL_LOGIN_SYSTEM_USER_ID or SYSTEM_USER_ID), or ZITADEL_SERVICE_USER_TOKEN",
|
||||
"No authentication credentials found. Set ZITADEL_LOGINCLIENT_KEYFILE, or system user credentials (AUDIENCE, SYSTEM_USER_ID, SYSTEM_USER_PRIVATE_KEY or SYSTEM_USER_PRIVATE_KEY_FILE), or ZITADEL_SERVICE_USER_TOKEN",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user