2019-12-08 09:17:36 -05:00
|
|
|
package authn
|
|
|
|
|
|
|
|
import (
|
2020-02-20 21:08:47 -05:00
|
|
|
model "github.com/HFO4/cloudreve/models"
|
|
|
|
"github.com/HFO4/cloudreve/pkg/util"
|
2019-12-08 09:17:36 -05:00
|
|
|
"github.com/duo-labs/webauthn/webauthn"
|
|
|
|
)
|
|
|
|
|
2019-12-08 22:33:39 -05:00
|
|
|
var AuthnInstance *webauthn.WebAuthn
|
2019-12-08 09:17:36 -05:00
|
|
|
|
2020-02-20 21:08:47 -05:00
|
|
|
// Init 初始化webauthn
|
2019-12-08 09:17:36 -05:00
|
|
|
func Init() {
|
|
|
|
var err error
|
2020-02-20 21:08:47 -05:00
|
|
|
base := model.GetSiteURL()
|
2019-12-08 22:33:39 -05:00
|
|
|
AuthnInstance, err = webauthn.New(&webauthn.Config{
|
2020-02-20 21:08:47 -05:00
|
|
|
RPDisplayName: model.GetSettingByName("siteName"), // Display Name for your site
|
|
|
|
RPID: base.Hostname(), // Generally the FQDN for your site
|
|
|
|
RPOrigin: base.String(), // The origin URL for WebAuthn requests
|
2019-12-08 09:17:36 -05:00
|
|
|
})
|
|
|
|
if err != nil {
|
2020-02-20 21:08:47 -05:00
|
|
|
util.Log().Error("无法初始化WebAuthn, %s", err)
|
2019-12-08 09:17:36 -05:00
|
|
|
}
|
|
|
|
}
|