fix(security): 🐛 handle errors in OAuth2 examples and passkey methods
Some checks failed
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in -22m52s
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Successful in -22m42s
Build , Vet Test, and Lint / Build (push) Successful in -26m19s
Build , Vet Test, and Lint / Lint Code (push) Successful in -25m40s
Tests / Unit Tests (push) Successful in -26m33s
Tests / Integration Tests (push) Failing after -26m55s

* Add error handling for JSON encoding and HTTP server calls.
* Update passkey examples to improve readability and maintainability.
* Ensure consistent use of error handling across all examples.
This commit is contained in:
2026-01-31 22:58:52 +02:00
parent 2e7b3e7abd
commit 7600a6d1fb
4 changed files with 48 additions and 45 deletions

View File

@@ -61,11 +61,11 @@ func (p *DatabasePasskeyProvider) BeginRegistration(ctx context.Context, userID
}
excludeCredentials := make([]PasskeyCredentialDescriptor, 0, len(credentials))
for _, cred := range credentials {
for i := range credentials {
excludeCredentials = append(excludeCredentials, PasskeyCredentialDescriptor{
Type: "public-key",
ID: cred.CredentialID,
Transports: cred.Transports,
ID: credentials[i].CredentialID,
Transports: credentials[i].Transports,
})
}
@@ -319,7 +319,8 @@ func (p *DatabasePasskeyProvider) GetCredentials(ctx context.Context, userID int
}
credentials := make([]PasskeyCredential, 0, len(rawCreds))
for _, raw := range rawCreds {
for i := range rawCreds {
raw := rawCreds[i]
credID, err := base64.StdEncoding.DecodeString(raw.CredentialID)
if err != nil {
continue