Feat: add read/write lock for authn

This commit is contained in:
HFO4
2020-02-23 15:33:53 +08:00
parent 3ce4b87f2b
commit ce2a70df68
4 changed files with 31 additions and 0 deletions

View File

@@ -4,12 +4,16 @@ import (
model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/util"
"github.com/duo-labs/webauthn/webauthn"
"sync"
)
var AuthnInstance *webauthn.WebAuthn
var Lock sync.RWMutex
// Init 初始化webauthn
func Init() {
Lock.Lock()
defer Lock.Unlock()
var err error
base := model.GetSiteURL()
AuthnInstance, err = webauthn.New(&webauthn.Config{