修复登录报错问题
This commit is contained in:
@@ -15,6 +15,7 @@ export type AuthRuntimeConfig = {
|
||||
scope: string;
|
||||
issuer: string;
|
||||
passwordEncryptionKey?: string;
|
||||
tenantId?: string;
|
||||
sessionSecret?: string;
|
||||
clockSkewSeconds: number;
|
||||
};
|
||||
@@ -23,10 +24,12 @@ export type AuthClientMode = "default" | "admin";
|
||||
|
||||
export function getAuthRuntimeConfig(options: { clientMode?: AuthClientMode } = {}): AuthRuntimeConfig {
|
||||
const authBaseUrl = trimTrailingSlash(envValue("ZHINIAN_AUTH_BASE_URL", "AUTH_BASE"));
|
||||
const client = authClientConfig(options.clientMode || "default");
|
||||
const clientMode = options.clientMode || "default";
|
||||
const client = authClientConfig(clientMode);
|
||||
const scope = envValue("ZHINIAN_AUTH_SCOPE", "AUTH_SCOPE") || "server";
|
||||
const issuer = envValue("ZHINIAN_AUTH_ISSUER", "AUTH_ISSUER") || "https://pig4cloud.com";
|
||||
const passwordEncryptionKey = envValue("ZHINIAN_AUTH_PASSWORD_ENC_KEY", "AUTH_PASSWORD_ENC_KEY", "AGENTBUS_SSO_PASSWORD_ENC_KEY");
|
||||
const tenantId = authTenantId(clientMode);
|
||||
const sessionSecret = envValue("ZHINIAN_AUTH_SESSION_SECRET", "AUTH_SESSION_SECRET", "NEXTAUTH_SECRET");
|
||||
const explicitRequired = boolEnv("ZHINIAN_AUTH_REQUIRED");
|
||||
const disabled = boolEnv("ZHINIAN_AUTH_DISABLED") === true;
|
||||
@@ -53,6 +56,7 @@ export function getAuthRuntimeConfig(options: { clientMode?: AuthClientMode } =
|
||||
scope,
|
||||
issuer,
|
||||
passwordEncryptionKey,
|
||||
tenantId,
|
||||
sessionSecret,
|
||||
clockSkewSeconds: numberEnv("ZHINIAN_AUTH_CLOCK_SKEW_SECONDS") ?? 60
|
||||
};
|
||||
@@ -122,6 +126,11 @@ function authClientConfig(mode: AuthClientMode): {
|
||||
};
|
||||
}
|
||||
|
||||
function authTenantId(mode: AuthClientMode): string | undefined {
|
||||
if (mode === "admin") return envValue("ZHINIAN_ADMIN_AUTH_TENANT_ID", "ADMIN_AUTH_TENANT_ID");
|
||||
return envValue("ZHINIAN_AUTH_TENANT_ID", "AUTH_TENANT_ID", "ZHINIAN_ORG_TENANT_ID");
|
||||
}
|
||||
|
||||
function boolEnv(name: string): boolean | undefined {
|
||||
const value = process.env[name]?.trim().toLowerCase();
|
||||
if (!value || value === "auto") return undefined;
|
||||
|
||||
@@ -70,6 +70,8 @@ const settingDefinitions: Array<{
|
||||
{ key: "ZHINIAN_AUTH_CLIENT_SECRET", label: "客户端密钥", secret: true, type: "password" },
|
||||
{ key: "ZHINIAN_ADMIN_AUTH_CLIENT_ID", label: "管理员客户端 ID", defaultValue: "app" },
|
||||
{ key: "ZHINIAN_ADMIN_AUTH_CLIENT_SECRET", label: "管理员客户端密钥", secret: true, type: "password" },
|
||||
{ key: "ZHINIAN_AUTH_TENANT_ID", label: "普通登录租户 ID", description: "为空时复用 ZHINIAN_ORG_TENANT_ID" },
|
||||
{ key: "ZHINIAN_ADMIN_AUTH_TENANT_ID", label: "管理员登录租户 ID", description: "通常留空,避免管理员登录被普通租户影响" },
|
||||
{ key: "ZHINIAN_AUTH_SCOPE", label: "Scope", defaultValue: "server" },
|
||||
{ key: "ZHINIAN_AUTH_ISSUER", label: "Issuer", defaultValue: "https://pig4cloud.com" },
|
||||
{ key: "ZHINIAN_AUTH_PASSWORD_ENC_KEY", label: "Password Encryption Key", secret: true, type: "password" },
|
||||
|
||||
Reference in New Issue
Block a user