-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Labels
onlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source week
Description
π Verify Biometric Credentials with WebAuthn π οΈ
π Description
Implement an API endpoint to verify biometric credentials (e.g., fingerprint or Face ID) using WebAuthn for the Stellar wallet service. This endpoint will allow users to authenticate by validating their WebAuthn credentials against stored public keys, ensuring secure access to protected routes and operations in the wallet service.
π― Objective
Create a POST /auth/verify endpoint in services/stellar-wallet/src/routes/auth-verify.js to verify WebAuthn credentials against the SQLite database, with a unit test to confirm functionality.
π Structure
- Directory:
services/stellar-wallet - Files:
src/routes/auth-verify.jstests/routes/auth-verify.test.js
- Expected structure:
services/stellar-wallet βββ src β βββ index.js β βββ stellar β β βββ client.js β β βββ keys.js β β βββ fund.js β βββ db β β βββ kyc.js β βββ routes β β βββ kyc.js β β βββ kyc-verify.js β β βββ kyc-status.js β β βββ auth-register.js β β βββ auth-verify.js β βββ kyc β β βββ validate.js β βββ soroban β β βββ client.js β β βββ kyc-contract.rs β β βββ deploy.js β βββ auth β βββ webauthn.js βββ config β βββ db.sqlite βββ tests β βββ stellar β β βββ client.test.js β β βββ keys.test.js β β βββ fund.test.js β βββ db β β βββ kyc.test.js β βββ routes β β βββ kyc.test.js β β βββ kyc-verify.test.js β β βββ kyc-status.test.js β β βββ auth-register.test.js β β βββ auth-verify.test.js β βββ kyc β β βββ validate.test.js β βββ soroban β βββ client.test.js β βββ deploy.test.js βββ package.json βββ .env.example βββ .eslintrc.json βββ .eslintignore βββ .prettierrc.json βββ .prettierignore βββ .gitignore
β Requirements
- Create a branch named
feat/webauthn-verifyfor this task. - Create
src/routes/auth-verify.jsto define aPOST /auth/verifyendpoint using Express. - Configure the endpoint to accept JSON input with
user_id(string, matching akyc_idfrom the SQLite database) and the WebAuthn authentication response. - Validate that
user_idexists in thecredentialstable (from Issue 17); return HTTP 400 with a JSON error message (e.g.,{ error: "Invalid user ID" }) if not found. - Use
generateAuthenticationOptionsfromsrc/auth/webauthn.js(Issue 16) to create WebAuthn authentication options for the client. - Verify the clientβs WebAuthn response using
@simplewebauthn/serveragainst the storedcredential_idandpublic_keyin thecredentialstable. - Return a JSON response with HTTP status 200 and details (e.g.,
{ user_id, verified: true }) if verification succeeds. - Handle errors (e.g., invalid WebAuthn response, non-existent credentials) with HTTP 401 or 500 and a JSON error message (e.g.,
{ error: "Authentication failed" }). - Create a unit test in
tests/routes/auth-verify.test.jsto verify:- Successful verification returns HTTP 200 with
verified: true. - Invalid
user_idor WebAuthn response returns HTTP 401 or 400.
- Successful verification returns HTTP 200 with
- Mock the WebAuthn server and SQLite database in the unit test to avoid external dependencies.
- Update
src/index.jsto mount the authentication verification routes at/auth/verify. - Ensure the code adheres to ESLint and Prettier rules (from Issue 3).
- Commit changes to the
feat/webauthn-verifybranch with a message likefeat: verify webauthn credentials. - Verify that the CI pipeline (from Issue 1) passes, with linting and test jobs succeeding.
π Expected Outcomes
src/routes/auth-verify.jsdefines aPOST /auth/verifyendpoint that verifies WebAuthn credentials.- Valid credentials are verified against the
credentialstable, returning HTTP 200 with a JSON response. - Invalid inputs or failed verifications return appropriate HTTP status codes and JSON error messages.
- Unit test in
tests/routes/auth-verify.test.jsconfirms correct behavior for valid and invalid inputs. - Express server mounts authentication verification routes correctly.
- Code passes ESLint and Prettier checks.
- Changes are committed to the
feat/webauthn-verifybranch with a descriptive lowercase commit message. - CI pipeline runs successfully, with linting passing for
src/routes/auth-verify.jsandtests/routes/auth-verify.test.js, and the unit test passing.
π References
- SimpleWebAuthn Server
- WebAuthn Authentication
- SQLite3 Node.js Package
- Jest Mocking
- ESLint Node.js Rules
π Notes
- The
user_idshould match akyc_idin thecredentialstable. - Mocking the WebAuthn server and SQLite database in tests ensures reliable CI execution.
- Ensure secure handling of credentials, avoiding exposure of sensitive data like
public_key. - Verification failures should return HTTP 401 to indicate unauthorized access.
- Commit messages must be in lowercase and start with
feat,change,fix,chore, orrefactor. - The CI pipeline should validate the new code, ensuring ESLint passes and the unit test executes successfully.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
onlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source week