diff --git a/apps/backend/src/oidc/config.ts b/apps/backend/src/oidc/config.ts index f67dd2e..c91b3f9 100644 --- a/apps/backend/src/oidc/config.ts +++ b/apps/backend/src/oidc/config.ts @@ -1,15 +1,38 @@ import { Configuration } from 'oidc-provider'; +import { nanoid } from 'nanoid'; const config: Configuration = { - clients: [ - { - client_id: 'example-client', - client_secret: 'example-secret', - grant_types: ['authorization_code'], - redirect_uris: ['http://localhost:3000/cb'], + 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天 }, - ], - // 其他配置项... }; export default config; \ No newline at end of file