feat: strengthen device authentication, linking, session security, an…#208
Open
devchant wants to merge 1 commit into
Open
feat: strengthen device authentication, linking, session security, an…#208devchant wants to merge 1 commit into
devchant wants to merge 1 commit into
Conversation
…d key-bundle abuse protection
|
@devchant Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: strengthen device authentication, linking, session security, and key-bundle abuse protection
Closes #165
Closes #167
Closes #169
Closes #164
Summary
This PR enhances device management and authentication security by introducing device-bound authentication, secure device linking, session revocation across devices, and abuse protection for key-bundle retrieval.
Implemented Features
#165 - Register First Device During Authentication Verification
Extended
POST /auth/verifyto require adevicepayload containing:Device registration now occurs immediately after successful signature verification.
Implemented idempotent device upsert using
(userId, deviceId)to prevent duplicate records.JWTs issued by the endpoint now include both:
userIddeviceIdAdded validation for the submitted identity public key.
Requests without a device payload now return
400 Bad Requestwith a clear client upgrade message.Acceptance Criteria
400with upgrade instructions.#167 - Secure Device Linking Challenge Flow
Added:
POST /auth/link-device/challengePOST /auth/link-device/verifyReused the existing SIWS nonce flow with a dedicated
"link"authentication mode.Device linking now requires a fresh wallet-signed challenge, preventing unauthorized device provisioning.
Successful verification routes through the existing device-registration workflow.
Newly linked devices are created without prekeys and bootstrap normally through subsequent key exchange.
Acceptance Criteria
#169 - Device Session Revocation ("Log Out Everywhere")
Added
POST /devices/revoke-all-except-current.Endpoint revokes every authenticated user's device except the currently active one.
Revocation workflow includes:
Endpoint returns the total number of revoked devices.
Acceptance Criteria
#164 - Key-Bundle Rate Limiting and Abuse Protection
Added layered rate limiting to
GET /key-bundleusingexpress-rate-limit.Implemented:
Added monitoring for abnormal one-time prekey consumption velocity to detect exhaustion attacks.
Excessive bundle requests now return
429 Too Many Requests.Consumption metrics and anomaly events are emitted for observability and alerting.
Acceptance Criteria
429.Security Improvements
Testing
Added comprehensive test coverage for:
Breaking Changes
POST /auth/verifynow requires adevicepayload.All tests pass successfully.