New: personal access token management API (fixes #97)#98
Merged
Conversation
|
🎉 This PR is included in version 2.9.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Fixes #97
Fixes #14
Fixes #95
Supersedes #96 — this branch includes and extends that scope-forwarding change, so #96 can be closed in favour of this PR.
New
name,expiresAtand a maskedhinton theauthtokenschema.adpt_pat_<fragment>_prefix and the full value is returned only once; the storedhintlets the owner recognise a token in a listing without exposing it.AuthToken.stripTokenPrefix()strips the prefix before verification, so session tokens (unprefixed) are unaffected.generateTokenHandlerforwardsname,lifespanandscopestoAuthToken.generate.lifespan: "never"mints a non-expiring token; otherwiseexpiresAtis persisted from the token's expiry.DELETE /tokens/:_idrevokes a single token owned by the current user (ownership-scoped by_id+userId).*:*); minting without scopes, or with*:*, still returnsSUPER_TOKEN_FORBIDDEN.Fix
GET /tokensno longer throwsMODIFY_PROTECTED_ATTR(Fix/tokensAPI endpoint #14): the sanitise call now runs non-strict, so internal fields (e.g.signature) are stripped from the response rather than rejected. The listing also carries_id, is limited to personal (manual) tokens, and returns an empty array when there are none.createObjectId(id), which ignores its argument and mints a new random id, so the query matched nothing. Switched toparseObjectId(id).Testing
resolveTokenScopes(super-lift cases),generateTokenHandler(name/lifespan/scopes forwarded; super no longer rejected outright),revokeTokenHandler(ownership-scoped, id parsed to an ObjectId) andstripTokenPrefix. Full suite (132) passes;standardclean.*:*; prefixed Bearer authentication and scope limiting; sanitised listing with_id; per-token revoke actually removing the record; revoked token rejected; empty listing.