fix: enforce minimum strength for learning-path tokens (issue #1874) - #1908
Open
ionfwsrijan wants to merge 1 commit into
Open
fix: enforce minimum strength for learning-path tokens (issue #1874)#1908ionfwsrijan wants to merge 1 commit into
ionfwsrijan wants to merge 1 commit into
Conversation
|
@ionfwsrijan is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
The learning-path APIs used the client-chosen
X-Learning-Path-Tokenas the only authorization secret but accepted any non-empty token. The route docstring only advised callers to use "a random UUID or similar"; there was no server-side length/entropy requirement, so trivially guessable tokens (e.g."test","1234") gave full read/write access to a user's learning-path state.Fix
_validate_token(src/utils/learning_path.py). Sincecreate_learning_path,get_learning_path, andupdate_learning_pathall validate the token, every learning-path route (create/read/update/analytics) now rejects weak tokens with HTTP 400 via the existingValueErrorhandling — no per-route changes needed.Files changed
src/utils/learning_path.py—_MIN_TOKEN_LENGTH = 16;_validate_tokenrejects tokens shorter than 16 characters with a clear message.src/routes/main_routes.py— docstrings for the four learning-path endpoints now state the enforced requirement (was advisory only).tests/test_learning_path.py— newTestWeakTokenRejectionclass with route-level tests asserting weak tokens on POST/GET/PUT return 400.Testing
tests/test_learning_path.py(minimal app stub sinceappcannot import locally due to the pre-existing App fails to boot: NameError: name 're' is not defined in portfolio_analyzer.py #1810) — 52 passed (48 existing + 4 new).secrets.token_urlsafe(32)produces 43-character tokens.Closes #1874