shared/lib/auth/types-v2.ts

30 lines
968 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// shared/lib/auth/types-v2.ts — V2 类型定义(步骤 1a 新增,旧 types.ts 不动)
// 与 V1 的关键差异SessionPayloadV2 含 iss不含 role认证与鉴权分离
export interface SessionPayloadV2 {
username: string
displayName?: string
/** JWT 签发者标识OA LDAP 用 "oa.tlyq.ai"OIDC 用 autheliaUrl */
iss: string
iat: number
exp: number
}
/** handleOidcCallback 中 getUser/createUser 返回的用户信息role 不写入 JWT */
export interface OidcCallbackUserInfo {
id: number
role: string
}
/** createMiddlewareV2 的配置 */
export interface MiddlewareV2Config {
jwtSecret: string
cookieDomain: string
/** 允许的 iss 值白名单。迁移期间可设为 ["*"](跳过白名单校验,仅验签名+过期),全量迁移后改为具体值 */
allowedIssuers: string[]
publicPaths?: string[]
enableApiKey?: boolean
/** 管理员角色名,默认 'admin' */
adminRole?: string
}