UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

51 lines (45 loc) 1.24 kB
import { OIDCConfig, OIDCUserConfig } from '@auth/core/providers'; import { CommonProviderConfig } from './sso.config'; interface CasdoorProfile extends Record<string, any> { avatar: string; displayName: string; email: string; emailVerified: boolean; firstName: string; id: string; lastName: string; name: string; owner: string; permanentAvatar: string; } function LobeCasdoorProvider(config: OIDCUserConfig<CasdoorProfile>): OIDCConfig<CasdoorProfile> { return { ...CommonProviderConfig, ...config, id: 'casdoor', name: 'Casdoor', profile(profile) { return { email: profile.email, emailVerified: profile.emailVerified ? new Date() : null, id: profile.id, image: profile.avatar, name: profile.displayName ?? profile.firstName ?? profile.lastName, providerAccountId: profile.id, }; }, type: 'oidc', }; } const provider = { id: 'casdoor', provider: LobeCasdoorProvider({ authorization: { params: { scope: 'openid profile email' }, }, clientId: process.env.AUTH_CASDOOR_ID, clientSecret: process.env.AUTH_CASDOOR_SECRET, issuer: process.env.AUTH_CASDOOR_ISSUER, }), }; export default provider;