File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,11 @@ type finishRegistrationResponse struct {
4242 KeyHandleHash string `json:"key_handle_hash"`
4343}
4444
45+ type finishLoginResponse struct {
46+ CredentialID string `json:"credentialId"` // DEPRECATED, use KeyHandleHash instead
47+ KeyHandleHash string `json:"key_handle_hash"`
48+ }
49+
4550func BeginRegistration (w http.ResponseWriter , r * http.Request ) {
4651 user , err := getUserFromContext (r )
4752 if err != nil {
@@ -120,8 +125,9 @@ func FinishLogin(w http.ResponseWriter, r *http.Request) {
120125 return
121126 }
122127
123- resp := map [string ]string {
124- "credentialId" : string (credential .ID ),
128+ resp := finishLoginResponse {
129+ CredentialID : string (credential .ID ),
130+ KeyHandleHash : hashAndEncodeKeyHandle (credential .ID ),
125131 }
126132
127133 jsonResponse (w , resp , http .StatusOK )
Original file line number Diff line number Diff line change @@ -583,9 +583,11 @@ func (ms *MfaSuite) Test_FinishLogin() {
583583 // Give user two different credentials to see them come through
584584 const credID1 = "11345678-1234-1234-1234-123456789012"
585585 credIDEncoded1 := base64 .StdEncoding .EncodeToString ([]byte (credID1 ))
586+ khh1 := hashAndEncodeKeyHandle ([]byte (credID1 ))
586587
587588 const credID2 = "22345678-1234-1234-1234-123456789012"
588589 credIDEncoded2 := base64 .StdEncoding .EncodeToString ([]byte (credID2 ))
590+ khh2 := hashAndEncodeKeyHandle ([]byte (credID2 ))
589591
590592 const challenge = "W8GzFU8pGjhoRbWrLDlamAfq_y4S1CZG1VuoeRLARrE"
591593
@@ -688,13 +690,15 @@ func (ms *MfaSuite) Test_FinishLogin() {
688690 httpReq : reqWithBody1 ,
689691 wantBodyContains : []string {
690692 `"credentialId":"` + credID1 + `"` ,
693+ `"key_handle_hash":"` + khh1 + `"` ,
691694 },
692695 },
693696 {
694697 name : "with second credential" ,
695698 httpReq : reqWithBody2 ,
696699 wantBodyContains : []string {
697700 `"credentialId":"` + credID2 + `"` ,
701+ `"key_handle_hash":"` + khh2 + `"` ,
698702 },
699703 },
700704 }
You can’t perform that action at this time.
0 commit comments