Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.

Commit 64a7928

Browse files
committed
fix: read passkey id/rawId from response wrapper in CompleteRegistration
1 parent 9c5ad93 commit 64a7928

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

internal/routes/passkeys.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,20 @@ func (h *PasskeyHandler) CompleteRegistration(w http.ResponseWriter, r *http.Req
159159
ClientDataJSON string `json:"clientDataJSON"`
160160
DeviceName string `json:"deviceName"`
161161
ResponseObj struct {
162+
ID string `json:"id"`
163+
RawID string `json:"rawId"`
162164
AttestationObject string `json:"attestationObject"`
163165
ClientDataJSON string `json:"clientDataJSON"`
164166
} `json:"response"`
165167
}
166168
json.NewDecoder(r.Body).Decode(&body)
167169

170+
if body.ID == "" {
171+
body.ID = body.ResponseObj.ID
172+
}
173+
if body.RawID == "" {
174+
body.RawID = body.ResponseObj.RawID
175+
}
168176
if body.ID == "" {
169177
jsonError(w, "Invalid passkey data", http.StatusBadRequest)
170178
return
@@ -181,8 +189,12 @@ func (h *PasskeyHandler) CompleteRegistration(w http.ResponseWriter, r *http.Req
181189
deviceName = "Unknown Device"
182190
}
183191

184-
credentialID, _ := base64.RawURLEncoding.DecodeString(body.RawID)
185-
if credentialID == nil {
192+
if body.RawID == "" {
193+
jsonError(w, "Invalid credential ID", http.StatusBadRequest)
194+
return
195+
}
196+
credentialID, err := base64.RawURLEncoding.DecodeString(body.RawID)
197+
if err != nil {
186198
jsonError(w, "Invalid credential ID", http.StatusBadRequest)
187199
return
188200
}
@@ -325,10 +337,6 @@ func (h *PasskeyHandler) CompleteLogin(w http.ResponseWriter, r *http.Request) {
325337
}
326338

327339
challengeMu.Lock()
328-
fmt.Printf("DEBUG CompleteLogin: sessionToken=%q mapSize=%d\n", body.SessionToken, len(challengeMap))
329-
for k := range challengeMap {
330-
fmt.Printf("DEBUG CompleteLogin: key=%q\n", k)
331-
}
332340
stored := challengeMap["login:"+body.SessionToken]
333341
if stored != nil {
334342
delete(challengeMap, "login:"+body.SessionToken)

0 commit comments

Comments
 (0)