yoake/internal/auth/yubikey.go
2022-11-07 05:45:02 -05:00

24 lines
481 B
Go

package auth
import (
"log"
"github.com/eternal-flame-AD/yoake/config"
"github.com/eternal-flame-AD/yubigo"
)
var yubiAuth *yubigo.YubiAuth
func yubiAuthLazyInit() {
if yubiAuth != nil {
return
}
conf := config.Config()
if conf.Auth.Method.Yubikey.ClientId != "" {
if a, err := yubigo.NewYubiAuth(conf.Auth.Method.Yubikey.ClientId, conf.Auth.Method.Yubikey.ClientKey); err != nil {
log.Panicf("failed to load yubigo: %v", err)
} else {
yubiAuth = a
}
}
}