fenghuo/apps/backend/src/oidc/config.ts

38 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-05-26 19:56:34 +08:00
import { Configuration } from 'oidc-provider';
2025-05-26 19:56:40 +08:00
import { nanoid } from 'nanoid';
2025-05-26 19:56:34 +08:00
const config: Configuration = {
2025-05-26 19:56:40 +08:00
clients: [
{
client_id: 'example-client',
client_secret: 'example-secret',
grant_types: ['authorization_code', 'refresh_token'],
redirect_uris: ['http://localhost:3000/callback'],
response_types: ['code'],
scope: 'openid email profile',
},
],
pkce: {
required: () => true, // 要求所有客户端使用PKCE
},
features: {
devInteractions: { enabled: false }, // 禁用开发交互界面
resourceIndicators: { enabled: true }, // 启用资源指示器
revocation: { enabled: true }, // 启用令牌撤销
userinfo: { enabled: true }, // 启用用户信息端点
},
cookies: {
keys: [nanoid()], // 用于签署和验证cookie
},
jwks: {
keys: [], // 在实际环境中应该生成并保存密钥
},
ttl: {
AccessToken: 3600, // 1小时
AuthorizationCode: 600, // 10分钟
IdToken: 3600, // 1小时
RefreshToken: 1209600, // 14天
},
2025-05-26 19:56:34 +08:00
};
export default config;