Skip to content

Commit

Permalink
log a message even if the error isn't a protocol.Error
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Nov 12, 2024
1 parent d6692e1 commit f6e352b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,6 @@ func (u *DynamoUser) FinishLogin(r *http.Request) (*webauthn.Credential, error)
return credential, nil
}

// logProtocolError logs a message if the given error is an Error from go-webauthn/webauthn/protocol
func logProtocolError(msg string, err error) {
var protocolError *protocol.Error
if errors.As(err, &protocolError) {
log.Printf("%s, ProtocolError: %s, DevInfo: %s", msg, protocolError.Details, protocolError.DevInfo)
}
}

// User ID according to the Relying Party
func (u *DynamoUser) WebAuthnID() []byte {
return []byte(u.ID)
Expand Down Expand Up @@ -489,3 +481,13 @@ func hashAndEncodeKeyHandle(id []byte) string {
hash := sha256.Sum256(id)
return base64.RawURLEncoding.EncodeToString(hash[:])
}

// logProtocolError logs a detailed message if the given error is an Error from go-webauthn/webauthn/protocol
func logProtocolError(msg string, err error) {
var protocolError *protocol.Error
if errors.As(err, &protocolError) {
log.Printf("%s, ProtocolError: %s, DevInfo: %s", msg, protocolError.Details, protocolError.DevInfo)
} else {
log.Printf("%s, Error: %s", msg, err)
}
}

0 comments on commit f6e352b

Please sign in to comment.