This commit is contained in:
parent
a6bcbaf5e9
commit
7ae75caaf5
3 changed files with 29 additions and 1 deletions
|
@ -9,6 +9,7 @@ package auth
|
|||
import (
|
||||
"time"
|
||||
|
||||
"git.mstar.dev/mstar/goutils/other"
|
||||
"git.mstar.dev/mstar/goutils/sliceutils"
|
||||
"github.com/go-webauthn/webauthn/webauthn"
|
||||
|
||||
|
@ -18,7 +19,8 @@ import (
|
|||
)
|
||||
|
||||
type Authenticator struct {
|
||||
webauthn *webauthn.WebAuthn
|
||||
webauthn *webauthn.WebAuthn
|
||||
recentlyUsedTotpTokens map[string]time.Time
|
||||
}
|
||||
type LoginNextState uint8
|
||||
|
||||
|
@ -33,6 +35,17 @@ const (
|
|||
LoginStartPasskey // Login starts with a passkey
|
||||
)
|
||||
|
||||
func New(webauthnConfig *webauthn.Config) (*Authenticator, error) {
|
||||
webauthn, err := webauthn.New(webauthnConfig)
|
||||
if err != nil {
|
||||
return nil, other.Error("auth", "failed to create webauthn handler", err)
|
||||
}
|
||||
return &Authenticator{
|
||||
webauthn: webauthn,
|
||||
recentlyUsedTotpTokens: make(map[string]time.Time),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func calcAccessExpirationTimestamp() time.Time {
|
||||
// For now, the default expiration is one month after creation
|
||||
// though "never" might also be a good option
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue