fix bugs
This commit is contained in:
@@ -62,6 +62,7 @@ func (u *WebAuthnUser) WebAuthnCredentialDescriptors() (descriptors []protocol.C
|
||||
|
||||
// WebAuthnService 提供WebAuthn相关功能
|
||||
type WebAuthnService struct {
|
||||
cfg *config.Config
|
||||
DB *gorm.DB
|
||||
WebAuthn *webauthn.WebAuthn
|
||||
// Sessions map[string]webauthn.SessionData // 用于存储注册和认证过程中的会话数据
|
||||
@@ -69,12 +70,12 @@ type WebAuthnService struct {
|
||||
}
|
||||
|
||||
// NewWebAuthnService 创建新的WebAuthn服务
|
||||
func NewWebAuthnService(db *gorm.DB, cfg *config.Config) (*WebAuthnService, error) {
|
||||
func NewWebAuthnService(cfg *config.Config, db *gorm.DB) (*WebAuthnService, error) {
|
||||
// 创建WebAuthn配置
|
||||
wconfig := &webauthn.Config{
|
||||
RPDisplayName: config.Cfg.AppName, // 依赖方(Relying Party)显示名称
|
||||
RPID: config.Cfg.Domain, // 依赖方ID(通常为域名)
|
||||
RPOrigins: []string{config.Cfg.AppURL}, // 依赖方源(URL)
|
||||
RPDisplayName: cfg.AppName, // 依赖方(Relying Party)显示名称
|
||||
RPID: cfg.RPID, // 依赖方ID(通常为域名)
|
||||
RPOrigins: cfg.RPOrigins, // 依赖方源(URL)
|
||||
AuthenticatorSelection: protocol.AuthenticatorSelection{
|
||||
RequireResidentKey: protocol.ResidentKeyRequired(), // 要求认证器存储用户 ID (resident key)
|
||||
ResidentKey: protocol.ResidentKeyRequirementRequired, // 使用 Discoverable 模式
|
||||
@@ -90,6 +91,7 @@ func NewWebAuthnService(db *gorm.DB, cfg *config.Config) (*WebAuthnService, erro
|
||||
}
|
||||
|
||||
return &WebAuthnService{
|
||||
cfg: cfg,
|
||||
DB: db,
|
||||
WebAuthn: wa,
|
||||
// Sessions: make(map[string]webauthn.SessionData),
|
||||
|
||||
Reference in New Issue
Block a user