自定义用户系统接入文档
1. 系统架构概述
项目采用了抽象的SSO接口设计,支持多种认证服务的接入。通过实现统一的 SSOInterface 接口,可以轻松集成自定义的用户系统。当前已支持两种认证服务:
- Casdoor :开源的身份和访问管理平台
- Paraview :一款闭源符合国标的身份认证系统
2. 核心接口定义
系统中所有SSO服务都必须实现 SSOInterface 接口,定义在 builder/rpc/sso.go 文件中:
// SSO接口定义了所有SSO服务必须实现的方法
type SSOInterface interface {
UpdateUserInfo(ctx context.Context, userInfo *SSOUpdateUserInfo) error
GetUserInfo(ctx context.Context, accessToken string) (*SSOUserInfo, error)
GetOAuthToken(ctx context.Context, code, state string) (*oauth2.Token, error)
DeleteUser(ctx context.Context, uuid string) error
IsExistByName(ctx context.Context, name string) (bool, error)
IsExistByEmail(ctx context.Context, email string) (bool, error)
IsExistByPhone(ctx context.Context, phone string) (bool, error)
CreateInvitation(ctx context.Context, code string) error
GetInvitationCode(ctx context.Context, userUUID string) (string, error)
}