add basic passkey template

This commit is contained in:
2026-08-03 06:04:02 -07:00
parent 1db9afd8cb
commit d34efd29ec
8 changed files with 953 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
package main
import "github.com/go-webauthn/webauthn/webauthn"
type User struct {
ID []byte
DisplayName string
Name string
creds []webauthn.Credential
}
func (o *User) WebAuthnID() []byte {
return o.ID
}
func (o *User) WebAuthnName() string {
return o.Name
}
func (o *User) WebAuthnDisplayName() string {
return o.DisplayName
}
func (o *User) WebAuthnIcon() string {
return "https://pics.com/avatar.png"
}
func (o *User) WebAuthnCredentials() []webauthn.Credential {
return o.creds
}
func (o *User) AddCredential(credential *webauthn.Credential) {
o.creds = append(o.creds, *credential)
}
func (o *User) UpdateCredential(credential *webauthn.Credential) {
for i, c := range o.creds {
if string(c.ID) == string(credential.ID) {
o.creds[i] = *credential
}
}
}