-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtypes.go
57 lines (45 loc) · 1.16 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package webauthn
import (
"github.com/fasthttp/session/v2"
"github.com/go-webauthn/webauthn/webauthn"
"github.com/valyala/fasthttp"
)
type UserSession struct {
Username string
Webauthn *webauthn.SessionData
}
type User struct {
ID string
Name string `json:"name"`
DisplayName string `json:"display_name"`
Icon string `json:"icon,omitempty"`
Credentials []webauthn.Credential `json:"credentials,omitempty"`
CredentialsSignIn []webauthn.Credential `json:"credentials_sign_in,omitempty"`
}
func (u User) WebAuthnID() []byte {
return []byte(u.ID)
}
func (u User) WebAuthnName() string {
return u.Name
}
func (u User) WebAuthnDisplayName() string {
return u.DisplayName
}
func (u User) WebAuthnIcon() string {
return u.Icon
}
func (u User) WebAuthnCredentials() []webauthn.Credential {
return u.Credentials
}
type WebauthnCtx struct {
fasthttp.RequestCtx
Providers Providers
}
type Providers struct {
User UserProvider
Session *session.Session
Webauthn *webauthn.WebAuthn
}
type UserProvider interface {
GetUser(username string) (user *User, err error)
}