Repository navigation
Tech-debt batch 9: typed app.state accessors; demo read-only on the resolved principal (#609 #611) - #614
Merged
Conversation
…app_state Closes #609 Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
…counts cannot mint tokens Closes #611 Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Deploying simple-module-python with
|
| Latest commit: |
41ae074
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://954770f4.simple-module-python.pages.dev |
| Branch Preview URL: | https://fix-debt-batch-9.simple-module-python.pages.dev |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Summary
simple_module_core.app_stateadds 19 typed accessors (get_public_routes,get_tenant_resolver,get_principal_serializer,get_auth_provider, …), each documenting what installs it. Framework code now readsapp.statethrough them instead ofgetattr(app.state, "<name>", None), and so do module reads of framework-level state. Behaviour is unchanged and the defaults match the old fallbacks.AuthState.principal_guardshook runs inAuthMiddlewareafter any credential resolves (session, bearer access token, personal API token). Users registers a guard that refuses unsafe methods from a demo account with the same allow-list and the same 403DEMO_READ_ONLY/ Inertia 409 response. The existing session guard stays.demo_read_onlyis on.POST /api/users/auth/tokenand/token/refreshreturn 403. A refused refresh does not consume the token, and a refresh token for a deactivated account is still burned on 401, as before.Closes #609
Closes #611
Residual risk
A demo account's bearer or refresh token that was issued before this change, or while
demo_read_onlywas off, can still write oncedemo_modeis switched off. At that point the configured demo-account list is empty. With this change, demo accounts can no longer get such tokens while read-only is on.Verification
make lintpassed.make test-py: 5975 passed.make test-js: 770 passed.QA Report
Test plan
POST /api/users/auth/tokenfor a demo account returns 403DEMO_READ_ONLY.https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4