30 lines
968 B
TypeScript
30 lines
968 B
TypeScript
// 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
|
||
}
|