From a96556d68409b392dd4f2ed2dca78e5e91ea8839 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Wed, 29 Nov 2023 08:42:26 +1100 Subject: [PATCH] fix(protocol): display name omitted incorrectly This fixes an issue where the displayName value for a user entity was omitted in error. See https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-user and https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity (and the same links for level 2). --- protocol/entities.go | 2 +- webauthn/registration_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/entities.go b/protocol/entities.go index 814e608..1d2f6e8 100644 --- a/protocol/entities.go +++ b/protocol/entities.go @@ -45,7 +45,7 @@ type UserEntity struct { // A human-palatable name for the user account, intended only for display. // For example, "Alex P. Müller" or "田中 倫". The Relying Party SHOULD let // the user choose this, and SHOULD NOT restrict the choice more than necessary. - DisplayName string `json:"displayName,omitempty"` + DisplayName string `json:"displayName"` // ID is the user handle of the user account entity. To ensure secure operation, // authentication and authorization decisions MUST be made on the basis of this id diff --git a/webauthn/registration_test.go b/webauthn/registration_test.go index ed689ab..a2c597d 100644 --- a/webauthn/registration_test.go +++ b/webauthn/registration_test.go @@ -35,8 +35,8 @@ func TestEntityEncoding(t *testing.T) { b64 bool have, expected string }{ - {"ShouldEncodeBase64", true, "abc", "{\"name\":\"\",\"id\":\"YWJj\"}"}, - {"ShouldEncodeString", false, "abc", "{\"name\":\"\",\"id\":\"abc\"}"}, + {"ShouldEncodeBase64", true, "abc", `{"name":"","displayName":"","id":"YWJj"}`}, + {"ShouldEncodeString", false, "abc", `{"name":"","displayName":"","id":"abc"}`}, } for _, tc := range testCases {