feat: 更新N5代理逻辑,支持使用用户JWKS令牌进行身份验证
This commit is contained in:
@@ -85,14 +85,17 @@ export class User {
|
||||
/**
|
||||
* 创建JWKS token的通用方法
|
||||
*/
|
||||
private static async createJwksTokenResponse(user: { id: string; username: string }, opts: { expire?: number } = {}) {
|
||||
static async createJwksTokenResponse(user: { id: string; username: string }, opts: { expire?: number, save?: boolean } = {}) {
|
||||
const expiresIn = opts?.expire ?? JWKS_TOKEN_EXPIRY;
|
||||
const save = opts?.save ?? true;
|
||||
const accessToken = await jwksManager.sign({
|
||||
sub: 'user:' + user.id,
|
||||
name: user.username,
|
||||
exp: Math.floor(Date.now() / 1000) + expiresIn,
|
||||
});
|
||||
await oauth.setJwksToken(accessToken, { id: user.id, expire: expiresIn });
|
||||
if (save) {
|
||||
await oauth.setJwksToken(accessToken, { id: user.id, expire: expiresIn });
|
||||
}
|
||||
|
||||
const token = {
|
||||
accessToken,
|
||||
|
||||
Reference in New Issue
Block a user