yoake/internal/auth/yubikey.go

25 lines
460 B
Go
Raw Normal View History

2022-11-07 04:45:02 -06:00
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()
2022-11-11 16:15:22 -06:00
if conf.Auth.Yubikey.ClientId != "" {
if a, err := yubigo.NewYubiAuth(conf.Auth.Yubikey.ClientId, conf.Auth.Yubikey.ClientKey); err != nil {
2022-11-07 04:45:02 -06:00
log.Panicf("failed to load yubigo: %v", err)
} else {
yubiAuth = a
}
}
}