Skip to content

Commit c7d933c

Browse files
feat(webauthn): credential message pack (#660)
This allows storing credentials with MessagePack.
1 parent 3c1e870 commit c7d933c

9 files changed

Lines changed: 2228 additions & 18 deletions

webauthn/authenticator.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@ import (
44
"github.com/go-webauthn/webauthn/protocol"
55
)
66

7+
//go:generate msgp
8+
9+
//msgp:replace protocol.AuthenticatorAttachment with:string
10+
711
// Authenticator represents a specific authenticator in the context of a [Credential].
812
type Authenticator struct {
913
// The AAGUID of the authenticator. An AAGUID is defined as an array containing the globally unique
1014
// identifier of the authenticator model being sought.
11-
AAGUID []byte `json:"AAGUID"`
15+
AAGUID []byte `json:"AAGUID" msg:"aaguid"`
1216

1317
// SignCount is a representation of the number of times the Authenticator or Credential have been used to login.
1418
// Upon a new login operation, the Relying Party compares the stored signature counter value with the new SignCount
1519
// value returned in the assertion’s authenticator data. If this new SignCount value is less than or equal to the
1620
// stored value, a cloned authenticator may exist, or the authenticator may be malfunctioning.
17-
SignCount uint32 `json:"signCount"`
21+
SignCount uint32 `json:"signCount" msg:"sc"`
1822

1923
// CloneWarning is a signal that the authenticator may be cloned, i.e. at least two copies of the
2024
// credential private key may exist and are being used in parallel. Relying Parties should incorporate
2125
// this information into their risk scoring. Whether the Relying Party updates the stored signature
2226
// counter value in this case, or not, or fails the authentication ceremony or not, is Relying Party-specific.
23-
CloneWarning bool `json:"cloneWarning"`
27+
CloneWarning bool `json:"cloneWarning" msg:"cw"`
2428

2529
// Attachment is the authenticatorAttachment value returned by the request.
26-
Attachment protocol.AuthenticatorAttachment `json:"attachment"`
30+
Attachment protocol.AuthenticatorAttachment `json:"attachment" msg:"aa"`
2731
}
2832

2933
// SelectAuthenticator is a convenience function that constructs a [protocol.AuthenticatorSelection] from individual

webauthn/authenticator_gen.go

Lines changed: 194 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webauthn/authenticator_gen_test.go

Lines changed: 123 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)