faststudio 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {faststudio-0.1.0 → faststudio-0.2.0}/CHANGELOG.md +191 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/PKG-INFO +25 -42
- faststudio-0.2.0/README.md +181 -0
- faststudio-0.2.0/THIRD_PARTY_NOTICES +45 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/examples/basic/README.md +22 -10
- {faststudio-0.1.0 → faststudio-0.2.0}/pyproject.toml +21 -4
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/__init__.py +8 -1
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/_spa.py +16 -2
- faststudio-0.2.0/src/faststudio/admin.py +478 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/_app.py +15 -2
- faststudio-0.2.0/src/faststudio/api/_authz.py +84 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/_context.py +6 -0
- faststudio-0.2.0/src/faststudio/api/_db_errors.py +53 -0
- faststudio-0.2.0/src/faststudio/api/_escalation.py +455 -0
- faststudio-0.2.0/src/faststudio/api/_many.py +147 -0
- faststudio-0.2.0/src/faststudio/api/_permission_sync.py +208 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/_records.py +19 -4
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/_serialize.py +35 -8
- faststudio-0.2.0/src/faststudio/api/_session_refresh.py +55 -0
- faststudio-0.2.0/src/faststudio/api/_startup_sync.py +104 -0
- faststudio-0.2.0/src/faststudio/api/auth.py +277 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/errors.py +13 -0
- faststudio-0.2.0/src/faststudio/api/models.py +181 -0
- faststudio-0.2.0/src/faststudio/api/passwords.py +156 -0
- faststudio-0.2.0/src/faststudio/api/sessions.py +48 -0
- faststudio-0.2.0/src/faststudio/api/write.py +499 -0
- faststudio-0.2.0/src/faststudio/auth/capabilities.py +303 -0
- faststudio-0.2.0/src/faststudio/auth/data/NOTICE +40 -0
- faststudio-0.2.0/src/faststudio/auth/data/common-passwords.txt.gz +0 -0
- faststudio-0.2.0/src/faststudio/auth/guard.py +244 -0
- faststudio-0.2.0/src/faststudio/auth/model_backend.py +486 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/auth/passwords.py +14 -0
- faststudio-0.2.0/src/faststudio/auth/permissions.py +69 -0
- faststudio-0.2.0/src/faststudio/auth/session.py +142 -0
- faststudio-0.2.0/src/faststudio/auth/validators.py +225 -0
- faststudio-0.2.0/src/faststudio/cli/__init__.py +118 -0
- faststudio-0.2.0/src/faststudio/cli/_app.py +117 -0
- faststudio-0.2.0/src/faststudio/cli/_commands.py +226 -0
- faststudio-0.2.0/src/faststudio/cli/_io.py +56 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/config.py +44 -5
- faststudio-0.2.0/src/faststudio/contrib/__init__.py +1 -0
- faststudio-0.2.0/src/faststudio/contrib/auth/__init__.py +35 -0
- faststudio-0.2.0/src/faststudio/contrib/auth/admins.py +89 -0
- faststudio-0.2.0/src/faststudio/contrib/auth/backend.py +337 -0
- faststudio-0.2.0/src/faststudio/contrib/auth/models.py +230 -0
- faststudio-0.2.0/src/faststudio/introspection/_many.py +181 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/introspection/_types.py +1 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/model_admin.py +67 -0
- faststudio-0.2.0/src/faststudio/query/_many.py +109 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/query/_params.py +39 -11
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/registry.py +206 -9
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/schemas/_dynamic.py +39 -6
- faststudio-0.2.0/src/faststudio/schemas/_meta.py +215 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/schemas/contract.py +83 -1
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/schemas/contract.schema.json +196 -6
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/security/csrf.py +23 -4
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/security/rate_limit.py +1 -1
- faststudio-0.2.0/src/faststudio/static/assets/ChangePasswordPage-C8txC4DA.js +1 -0
- faststudio-0.2.0/src/faststudio/static/assets/ListPage-Bqd3NgdP.js +1 -0
- faststudio-0.2.0/src/faststudio/static/assets/LoginPage-CvoSKj77.js +55 -0
- faststudio-0.2.0/src/faststudio/static/assets/PasswordFields-BdPw7SHL.js +1 -0
- faststudio-0.2.0/src/faststudio/static/assets/RecordPages-Cc4H_7KW.js +1 -0
- faststudio-0.2.0/src/faststudio/static/assets/index-BJWGi3om.js +12 -0
- faststudio-0.2.0/src/faststudio/static/assets/index-BvTc6fFC.css +2 -0
- faststudio-0.2.0/src/faststudio/static/assets/index.esm-CofRWSod.js +1 -0
- faststudio-0.2.0/src/faststudio/static/assets/query-C5UIFEci.js +1 -0
- faststudio-0.2.0/src/faststudio/static/assets/text-DlPvSGo4.js +1 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/static/index.html +2 -2
- faststudio-0.2.0/tests/_databases.py +52 -0
- faststudio-0.2.0/tests/_guards.py +12 -0
- faststudio-0.2.0/tests/_leaks.py +72 -0
- faststudio-0.2.0/tests/compat/test_v0_1_0.py +239 -0
- faststudio-0.2.0/tests/compat/v0_1_0/SNAPSHOT.md +22 -0
- faststudio-0.2.0/tests/compat/v0_1_0/basic/__init__.py +1 -0
- faststudio-0.2.0/tests/compat/v0_1_0/basic/app.py +103 -0
- faststudio-0.2.0/tests/compat/v0_1_0/basic/db.py +100 -0
- faststudio-0.2.0/tests/compat/v0_1_0/basic/models.py +96 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/conftest.py +16 -1
- faststudio-0.2.0/tests/e2e/idle_server.py +83 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/e2e/test_wheel_smoke.py +53 -0
- faststudio-0.2.0/tests/factories/auth_models.py +290 -0
- faststudio-0.2.0/tests/factories/contrib_models.py +22 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/factories/models.py +127 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/api/conftest.py +13 -2
- faststudio-0.2.0/tests/integration/api/test_client_disconnect.py +92 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/api/test_list.py +28 -0
- faststudio-0.2.0/tests/integration/api/test_many_to_many.py +771 -0
- faststudio-0.2.0/tests/integration/api/test_query_budget.py +26 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/api/test_retrieve_and_choices.py +8 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/api/test_write.py +17 -1
- faststudio-0.2.0/tests/integration/cli/_sync_worker.py +91 -0
- faststudio-0.2.0/tests/integration/cli/apps.py +198 -0
- faststudio-0.2.0/tests/integration/cli/conftest.py +36 -0
- faststudio-0.2.0/tests/integration/cli/test_cli.py +798 -0
- faststudio-0.2.0/tests/integration/cli/test_startup_sync.py +295 -0
- faststudio-0.2.0/tests/integration/cli/test_startup_sync_concurrency.py +134 -0
- faststudio-0.2.0/tests/integration/contrib/test_alembic.py +83 -0
- faststudio-0.2.0/tests/integration/contrib/test_contrib_auth.py +607 -0
- faststudio-0.2.0/tests/integration/security/_accounts.py +98 -0
- faststudio-0.2.0/tests/integration/security/conftest.py +83 -0
- faststudio-0.2.0/tests/integration/security/test_account_guard.py +230 -0
- faststudio-0.2.0/tests/integration/security/test_account_guard_servers.py +212 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/security/test_auth.py +241 -56
- faststudio-0.2.0/tests/integration/security/test_authorization.py +624 -0
- faststudio-0.2.0/tests/integration/security/test_escalation.py +539 -0
- faststudio-0.2.0/tests/integration/security/test_login_limit_servers.py +108 -0
- faststudio-0.2.0/tests/integration/security/test_passwords.py +438 -0
- faststudio-0.2.0/tests/integration/security/test_session_idle.py +192 -0
- faststudio-0.2.0/tests/integration/security/test_sign_out_everywhere.py +300 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/test_example_app.py +61 -7
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/test_spa.py +2 -1
- faststudio-0.2.0/tests/unit/api/test_db_errors.py +55 -0
- faststudio-0.2.0/tests/unit/api/test_lock_record.py +62 -0
- faststudio-0.2.0/tests/unit/api/test_lost_race.py +53 -0
- faststudio-0.2.0/tests/unit/api/test_rate_limit_key.py +92 -0
- faststudio-0.2.0/tests/unit/api/test_session_refresh.py +32 -0
- faststudio-0.2.0/tests/unit/api/test_write_commit.py +78 -0
- faststudio-0.2.0/tests/unit/auth/test_account_guard.py +235 -0
- faststudio-0.2.0/tests/unit/auth/test_account_guard_mappings.py +192 -0
- faststudio-0.2.0/tests/unit/auth/test_capabilities.py +334 -0
- faststudio-0.2.0/tests/unit/auth/test_permission_schema.py +472 -0
- faststudio-0.2.0/tests/unit/auth/test_session_idle.py +160 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/auth/test_tokens.py +3 -1
- faststudio-0.2.0/tests/unit/auth/test_validators.py +170 -0
- faststudio-0.2.0/tests/unit/cli/__init__.py +0 -0
- faststudio-0.2.0/tests/unit/cli/test_cli_unit.py +52 -0
- faststudio-0.2.0/tests/unit/introspection/__init__.py +0 -0
- faststudio-0.2.0/tests/unit/introspection/test_many.py +254 -0
- faststudio-0.2.0/tests/unit/query/__init__.py +0 -0
- faststudio-0.2.0/tests/unit/query/test_params.py +144 -0
- faststudio-0.2.0/tests/unit/schemas/__init__.py +0 -0
- faststudio-0.2.0/tests/unit/schemas/test_account_meta.py +72 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/schemas/test_contract.py +8 -2
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/schemas/test_dynamic.py +6 -1
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/schemas/test_export_contract.py +3 -0
- faststudio-0.2.0/tests/unit/security/__init__.py +0 -0
- faststudio-0.2.0/tests/unit/test_build_common_passwords.py +110 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_config.py +55 -1
- faststudio-0.2.0/tests/unit/test_contrib_auth_backend.py +86 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_docs.py +128 -11
- faststudio-0.2.0/tests/unit/test_leak_guard.py +33 -0
- faststudio-0.2.0/tests/unit/test_many_to_many_options.py +181 -0
- faststudio-0.2.0/tests/unit/test_model_accounts.py +55 -0
- faststudio-0.2.0/tests/unit/test_no_test_hooks.py +173 -0
- faststudio-0.2.0/tests/unit/test_package.py +124 -0
- faststudio-0.2.0/tests/unit/test_permission_options.py +159 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_spa.py +4 -1
- faststudio-0.2.0/tests/unit/test_third_party_notices.py +72 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_verify_wheel.py +5 -0
- faststudio-0.1.0/src/faststudio/admin.py +0 -227
- faststudio-0.1.0/src/faststudio/api/auth.py +0 -135
- faststudio-0.1.0/src/faststudio/api/models.py +0 -95
- faststudio-0.1.0/src/faststudio/api/write.py +0 -159
- faststudio-0.1.0/src/faststudio/auth/model_backend.py +0 -207
- faststudio-0.1.0/src/faststudio/auth/session.py +0 -78
- faststudio-0.1.0/src/faststudio/schemas/_meta.py +0 -101
- faststudio-0.1.0/src/faststudio/static/assets/ListPage-_dV1b5eQ.js +0 -1
- faststudio-0.1.0/src/faststudio/static/assets/RecordPages-DqN2e2EH.js +0 -1
- faststudio-0.1.0/src/faststudio/static/assets/index-BQwHVfIa.js +0 -66
- faststudio-0.1.0/src/faststudio/static/assets/index-Ch4jsWay.css +0 -2
- faststudio-0.1.0/src/faststudio/static/assets/query-56TKFQKO.js +0 -1
- faststudio-0.1.0/tests/unit/api/test_write_commit.py +0 -53
- faststudio-0.1.0/tests/unit/query/test_params.py +0 -80
- faststudio-0.1.0/tests/unit/test_package.py +0 -29
- faststudio-0.1.0/tools/name-reservation/LICENSE +0 -21
- faststudio-0.1.0/tools/name-reservation/README.md +0 -15
- {faststudio-0.1.0 → faststudio-0.2.0}/.gitignore +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/LICENSE +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/hatch_build.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/_deps.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/api/_paths.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/auth/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/auth/backend.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/auth/cookies.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/auth/csrf.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/exceptions.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/introspection/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/introspection/_columns.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/introspection/_fields.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/py.typed +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/query/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/query/_list.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/query/_write.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/schemas/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/security/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/security/headers.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/security/origin.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/src/faststudio/security/secret.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/_stubs.py +0 -0
- {faststudio-0.1.0/tests/e2e → faststudio-0.2.0/tests/compat}/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0/tests/compat/v0_1_0}/README.md +0 -0
- {faststudio-0.1.0/tests/factories → faststudio-0.2.0/tests/compat/v0_1_0}/__init__.py +0 -0
- {faststudio-0.1.0/tests/integration → faststudio-0.2.0/tests/e2e}/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/e2e/conftest.py +0 -0
- {faststudio-0.1.0/tests/integration/api → faststudio-0.2.0/tests/factories}/__init__.py +0 -0
- {faststudio-0.1.0/tests/integration/security → faststudio-0.2.0/tests/integration}/__init__.py +0 -0
- {faststudio-0.1.0/tests/unit → faststudio-0.2.0/tests/integration/api}/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/api/test_list_injection.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/api/test_meta.py +0 -0
- {faststudio-0.1.0/tests/unit/api → faststudio-0.2.0/tests/integration/cli}/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/conftest.py +0 -0
- {faststudio-0.1.0/tests/unit/auth → faststudio-0.2.0/tests/integration/contrib}/__init__.py +0 -0
- {faststudio-0.1.0/tests/unit/introspection → faststudio-0.2.0/tests/integration/security}/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/security/test_headers.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/security/test_origin.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/integration/test_errors.py +0 -0
- {faststudio-0.1.0/tests/unit/query → faststudio-0.2.0/tests/unit}/__init__.py +0 -0
- {faststudio-0.1.0/tests/unit/schemas → faststudio-0.2.0/tests/unit/api}/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/api/test_errors.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/api/test_serialize.py +0 -0
- {faststudio-0.1.0/tests/unit/security → faststudio-0.2.0/tests/unit/auth}/__init__.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/auth/test_model_backend.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/auth/test_passwords.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/introspection/test_fields.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/security/test_asgi_wrappers.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/security/test_rate_limit.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/security/test_secret.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_admin_init.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_authenticated_user.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_changelog_notes.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_check_commit_msg.py +0 -0
- {faststudio-0.1.0 → faststudio-0.2.0}/tests/unit/test_model_admin_validation.py +0 -0
|
@@ -7,6 +7,194 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
While in `0.x`, minor releases may contain breaking changes; they are always
|
|
8
8
|
listed under **Changed** or **Removed** with migration notes.
|
|
9
9
|
|
|
10
|
+
## [Unreleased]
|
|
11
|
+
|
|
12
|
+
## [0.2.0] - 2026-11-30
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Many-to-many fields (ADR-0010). `ModelAdmin.many_to_many` opts in
|
|
17
|
+
relationships over a plain association table, edited as a list of target
|
|
18
|
+
keys. `ModelAdmin.many_to_many_limits` sets the most keys per field
|
|
19
|
+
(default 500, at most 10 000). Both are validated at registration.
|
|
20
|
+
- API contract (additive, `schema_version` stays `"1"`):
|
|
21
|
+
- `FieldType` `"many_to_many"`;
|
|
22
|
+
- `FieldMeta.max_items`;
|
|
23
|
+
- `Row.many_labels` and `Row.truncated`;
|
|
24
|
+
- the choices endpoint for many-to-many fields;
|
|
25
|
+
- `GET /models/{identity}/items/{pk}/links`: how many many-to-many links
|
|
26
|
+
deleting the record would remove, per field (`LinkCountsResponse`);
|
|
27
|
+
- a documented forward-compatibility rule for clients.
|
|
28
|
+
- Admin UI: many-to-many fields are edited with a searchable multi-select
|
|
29
|
+
(removable chips, keyboard support, further pages loaded on scroll). Fields
|
|
30
|
+
truncated on a record are shown read-only with an explanation and are
|
|
31
|
+
never sent. The delete confirmation lists the links the delete removes.
|
|
32
|
+
- The example app has `Tag` and a `Task.tags` many-to-many field.
|
|
33
|
+
- Authorization (ADR-0011):
|
|
34
|
+
- backend capabilities: `faststudio_capabilities` returning
|
|
35
|
+
`BackendCapabilities`, with `PermissionBackend` and `PermissionSchema`
|
|
36
|
+
in `faststudio.auth.capabilities`;
|
|
37
|
+
- the public account guard in `faststudio.auth.guard`, and
|
|
38
|
+
`FlagAccountGuard`;
|
|
39
|
+
- async permission hooks on `ModelAdmin`;
|
|
40
|
+
- `ModelAdmin.extra_permissions`;
|
|
41
|
+
- `faststudio.has_perm` and `faststudio.ALL`.
|
|
42
|
+
- Every route is authorized per model:
|
|
43
|
+
- `/meta` lists only viewable models;
|
|
44
|
+
- labels and choices of models the admin may not view are withheld;
|
|
45
|
+
- create without view returns a minimal `Row`.
|
|
46
|
+
- Escalation rules: nobody grants a permission they do not hold, whichever
|
|
47
|
+
side of a relationship the write comes from. Only admins holding every
|
|
48
|
+
permission may change the superuser-like flag or touch such accounts.
|
|
49
|
+
- API contract (additive): `PermissionsMeta.view`, `AccountMeta.admin_flag`.
|
|
50
|
+
- Admin UI: a "Not found or no access" page.
|
|
51
|
+
- `faststudio.contrib.auth`: `AuthModels(Base)` (users, groups,
|
|
52
|
+
permissions on your declarative base), `DatabaseAuthBackend` (sign-in,
|
|
53
|
+
superusers, per-user and group permissions, escalation rules, passwords),
|
|
54
|
+
and the users/groups/permissions admins (`user_admin`, `group_admin`,
|
|
55
|
+
`permission_admin` to customize). For admin staff accounts only.
|
|
56
|
+
- The `faststudio` command line (ADR-0012): `createadmin`,
|
|
57
|
+
`changepassword`, `syncpermissions` (`--dry-run`, `--prune`, `--yes`) and
|
|
58
|
+
`checkusers` (`--fix`). Passwords are only read interactively, twice.
|
|
59
|
+
`--app` takes an `Admin`, a FastAPI application with one `Admin` mounted,
|
|
60
|
+
or a factory returning either (e.g. `examples.basic.app:create_app`).
|
|
61
|
+
- `Admin(sync_permissions_on_startup=True)`. Several processes starting at
|
|
62
|
+
once sync without errors or log noise (a deadlock victim is retried after
|
|
63
|
+
a short backoff).
|
|
64
|
+
- `AccountManager.find_account`, `required_fields` and `create_admin`;
|
|
65
|
+
`BackendCapabilities.username_audit` (`UsernameAudit`, `AuditedAccount`);
|
|
66
|
+
`PermissionSchema.name_field`.
|
|
67
|
+
- Public password helpers in `faststudio.auth.passwords` for custom
|
|
68
|
+
backends: `hash_password_async`, `verify_password_async`,
|
|
69
|
+
`dummy_verify_async`, `prepare_dummy_hash`, `is_password_hash` (with the
|
|
70
|
+
existing `hash_password`).
|
|
71
|
+
- `AccountGuard.secret_fields` (enforced at `register()`; a required member
|
|
72
|
+
of the not yet released `AccountGuard` protocol, so custom guards written
|
|
73
|
+
against earlier development builds must add it) and
|
|
74
|
+
`BackendCapabilities.register_admins`.
|
|
75
|
+
- Passwords (ADR-0011, ADR-0013):
|
|
76
|
+
- validators in `faststudio.auth.validators` (`DEFAULT_VALIDATORS`:
|
|
77
|
+
length, similarity to name and email, not only digits, not one of
|
|
78
|
+
20 000 common passwords). `CommonPasswordValidator()` uses a bundled
|
|
79
|
+
list from Dropbox zxcvbn (MIT; provenance in
|
|
80
|
+
`faststudio/auth/data/NOTICE` and `THIRD_PARTY_NOTICES`), or your own
|
|
81
|
+
file;
|
|
82
|
+
- the `accounts` capability (`AccountManager`) and `password_endpoints`;
|
|
83
|
+
- `ModelUserBackend(password_validators=..., password_endpoints=False)`;
|
|
84
|
+
- `POST /auth/password` and `POST /models/{identity}/items/{pk}/password`;
|
|
85
|
+
- "Change password" and "Set password" in the UI;
|
|
86
|
+
- contract (additive): `MetaResponse.capabilities`,
|
|
87
|
+
`AccountMeta.set_password`.
|
|
88
|
+
- Sessions (ADR-0013):
|
|
89
|
+
- `Admin(session_idle_timeout=...)` (off by default): sessions also end
|
|
90
|
+
after that long without a request, and active ones slide. Off, the
|
|
91
|
+
session cookie is unchanged from 0.1.x. Enable it only once every worker
|
|
92
|
+
runs 0.2 (0.1 workers refuse the longer cookie);
|
|
93
|
+
- `Admin(session_max_age=...)` also accepts int seconds;
|
|
94
|
+
- "Sign out everywhere": `POST /auth/sign-out-everywhere`, a header button,
|
|
95
|
+
the `session_revocation` capability (`SessionRevocation` in
|
|
96
|
+
`faststudio.auth.capabilities`) and
|
|
97
|
+
`MetaResponse.capabilities.sign_out_everywhere`. `contrib.auth`
|
|
98
|
+
provides it; `ModelUserBackend(session_token_field=...)` names a string
|
|
99
|
+
column of your user model for it (turning it on signs everyone out once);
|
|
100
|
+
- a save that meets an expired session asks for the password in place and
|
|
101
|
+
retries with the original input.
|
|
102
|
+
|
|
103
|
+
- Tested databases are documented (SQLite with Python 3.11–3.13,
|
|
104
|
+
PostgreSQL 17, MySQL 8.4 LTS with `aiomysql[rsa]`); CI runs the MySQL
|
|
105
|
+
suite.
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
|
|
109
|
+
- The public API is now defined per module: in a public module (listed in
|
|
110
|
+
docs/architecture.md, "Public API") the public names are exactly its
|
|
111
|
+
`__all__`. `faststudio.admin`, `faststudio.model_admin` and
|
|
112
|
+
`faststudio.auth.session` gained an `__all__`.
|
|
113
|
+
- The login rate limit treats spellings that MySQL's default collation
|
|
114
|
+
signs in as one account as one username: besides case and width, also
|
|
115
|
+
accents (`José` / `jose`), invisible characters (soft hyphen, zero-width
|
|
116
|
+
space) and stroke letters (`ø` / `o`).
|
|
117
|
+
- The login rate limit also counts attempts per matched account (per client
|
|
118
|
+
address) when the auth backend provides the `accounts` capability
|
|
119
|
+
(`ModelUserBackend`, `contrib.auth`). Every spelling the database signs in
|
|
120
|
+
as one account, including collation look-alikes the username key misses
|
|
121
|
+
(`🅐lice` on MySQL), now shares that account's budget. Password changes
|
|
122
|
+
count against the same keys. When only the account's budget is used up,
|
|
123
|
+
login answers `401 invalid_credentials` (not 429), so a look-alike cannot
|
|
124
|
+
reveal whether an account exists. Throttled requests never query the
|
|
125
|
+
database. `RateLimiter` implementations see more keys (keys are opaque
|
|
126
|
+
strings); the protocol is unchanged.
|
|
127
|
+
- The admin UI's first download is about a quarter smaller (main script
|
|
128
|
+
505 kB → 375 kB, gzip 160 kB → 121 kB): the login page and its form
|
|
129
|
+
libraries load only when needed.
|
|
130
|
+
- A write (POST, PATCH, DELETE) sent with an expired session cookie now
|
|
131
|
+
gets `401 not_authenticated` instead of `403 csrf_failed`, with the dead
|
|
132
|
+
cookie cleared; nothing runs in either case.
|
|
133
|
+
- The README and getting-started create the first admin with
|
|
134
|
+
`faststudio createadmin`; the v0.1 `create_admin.py` script is kept under
|
|
135
|
+
"Without the CLI".
|
|
136
|
+
- Auth backends that still implement 0.1.1's private account-guard methods
|
|
137
|
+
without `faststudio_capabilities` fail at startup instead of silently
|
|
138
|
+
losing their guard. `ModelUserBackend` provides its guard through
|
|
139
|
+
`faststudio_capabilities`; its private `guards`, `before_write`,
|
|
140
|
+
`check_model` and `protected_fields` methods are gone, so a subclass that
|
|
141
|
+
overrode them must move its rules into an `AccountGuard` (startup logs a
|
|
142
|
+
warning while such methods exist). Creates now reach the account guard
|
|
143
|
+
(`WriteIntent.action == "create"`).
|
|
144
|
+
- Deleting a record removes the links of its opted-in many-to-many fields,
|
|
145
|
+
and of opted-in fields of other models pointing at it, instead of
|
|
146
|
+
answering `409`. Relationships that are not opted in behave as before.
|
|
147
|
+
- Foreign-key labels are loaded in chunks of at most 500 keys per query.
|
|
148
|
+
- Many-to-many writes lock the record's row with `SELECT ... FOR UPDATE` on
|
|
149
|
+
PostgreSQL and MySQL/MariaDB, so host `ON UPDATE` triggers never fire when
|
|
150
|
+
only links change. On SQLite a no-change `UPDATE` takes the write lock,
|
|
151
|
+
so SQLite triggers do fire. Under PostgreSQL REPEATABLE READ, concurrent
|
|
152
|
+
link edits of one record may merge (documented).
|
|
153
|
+
|
|
154
|
+
### Fixed
|
|
155
|
+
|
|
156
|
+
- A browser that disconnects while sending a create or edit no longer
|
|
157
|
+
produces a server traceback ("Exception in ASGI application") or an
|
|
158
|
+
error log; one debug line is logged instead.
|
|
159
|
+
|
|
160
|
+
## [0.1.1] - 2026-11-24
|
|
161
|
+
|
|
162
|
+
### Added
|
|
163
|
+
|
|
164
|
+
- `Admin(max_list_offset=...)` and the matching `max_list_offset` field in the
|
|
165
|
+
SPA's runtime config.
|
|
166
|
+
- Error codes `self_lockout` and `last_admin` in the API contract.
|
|
167
|
+
- `ModelMeta.account` (additive, `schema_version` stays `"1"`): on the model
|
|
168
|
+
that holds the admins' accounts it lists the fields an admin cannot change
|
|
169
|
+
on their own record. The UI shows them read-only there and hides the delete
|
|
170
|
+
button; the server enforces the rule regardless.
|
|
171
|
+
|
|
172
|
+
### Changed
|
|
173
|
+
|
|
174
|
+
- Lists and relation pickers stop at `max_list_offset` rows (default
|
|
175
|
+
10 000): a page is reachable while `(page - 1) * page_size` is below it,
|
|
176
|
+
and pages past that now return `400 invalid_query`. Before, pages up to
|
|
177
|
+
100 000 were accepted (an `OFFSET` of up to 10 million rows). Response
|
|
178
|
+
shapes are unchanged. **Migration:** pass
|
|
179
|
+
`Admin(max_list_offset=...)` (up to 10 000 000) to restore deeper paging.
|
|
180
|
+
- With `ModelUserBackend`, `Admin.register()` now raises `ConfigurationError`
|
|
181
|
+
for a model that maps the user model's table without being the user model
|
|
182
|
+
or a subclass of it (an inheritance base class, a sibling subclass sharing
|
|
183
|
+
the table, or a second class on the same table), because writes through it
|
|
184
|
+
would bypass the account-safety checks. **Migration:** register the user
|
|
185
|
+
model itself (or a subclass of it).
|
|
186
|
+
|
|
187
|
+
### Fixed
|
|
188
|
+
|
|
189
|
+
- An admin could lock themselves out: clearing their own `is_admin` /
|
|
190
|
+
`is_active` flag or deleting their own row in the registered user model
|
|
191
|
+
succeeded, and every later request returned 401. These writes now return
|
|
192
|
+
`409 self_lockout`, and no write can remove the last active admin
|
|
193
|
+
(`409 last_admin`, checked atomically in the write's transaction; ADR-0009).
|
|
194
|
+
- Writes that lose a race to a concurrent request (SQLite "database is
|
|
195
|
+
locked", serialization failures, deadlocks, or an update of a row deleted
|
|
196
|
+
meanwhile) return `409 conflict` instead of `500`.
|
|
197
|
+
|
|
10
198
|
## [0.1.0] - 2026-11-24
|
|
11
199
|
|
|
12
200
|
### Added
|
|
@@ -170,4 +358,7 @@ listed under **Changed** or **Removed** with migration notes.
|
|
|
170
358
|
(`E2EUser` -> "E2E users", previously "E2 E users").
|
|
171
359
|
|
|
172
360
|
|
|
361
|
+
[Unreleased]: https://github.com/bekzod818/faststudio/compare/v0.2.0...HEAD
|
|
362
|
+
[0.2.0]: https://github.com/bekzod818/faststudio/releases/tag/v0.2.0
|
|
363
|
+
[0.1.1]: https://github.com/bekzod818/faststudio/releases/tag/v0.1.1
|
|
173
364
|
[0.1.0]: https://github.com/bekzod818/faststudio/releases/tag/v0.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: faststudio
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Plug-and-play admin panel for FastAPI and SQLAlchemy 2.0 with a modern React UI.
|
|
5
5
|
Project-URL: Homepage, https://github.com/bekzod818/faststudio
|
|
6
6
|
Project-URL: Repository, https://github.com/bekzod818/faststudio
|
|
@@ -9,6 +9,7 @@ Project-URL: Changelog, https://github.com/bekzod818/faststudio/blob/main/CHANGE
|
|
|
9
9
|
Author: Bekzod
|
|
10
10
|
License-Expression: MIT
|
|
11
11
|
License-File: LICENSE
|
|
12
|
+
License-File: THIRD_PARTY_NOTICES
|
|
12
13
|
Keywords: admin,admin-panel,crud,dashboard,fastapi,react,sqlalchemy,starlette
|
|
13
14
|
Classifier: Development Status :: 3 - Alpha
|
|
14
15
|
Classifier: Environment :: Web Environment
|
|
@@ -57,7 +58,7 @@ filtering and editing your data. No Node.js required: the UI ships pre-built
|
|
|
57
58
|
inside the Python wheel.
|
|
58
59
|
|
|
59
60
|
<p align="center">
|
|
60
|
-
<img alt="The products list in FastStudio: search, filters, sortable columns and pagination" src="https://raw.githubusercontent.com/bekzod818/faststudio/
|
|
61
|
+
<img alt="The products list in FastStudio: search, filters, sortable columns and pagination" src="https://raw.githubusercontent.com/bekzod818/faststudio/main/docs/assets/screenshot-list.png" width="860">
|
|
61
62
|
</p>
|
|
62
63
|
|
|
63
64
|
## Features
|
|
@@ -78,9 +79,13 @@ inside the Python wheel.
|
|
|
78
79
|
## Quickstart
|
|
79
80
|
|
|
80
81
|
```bash
|
|
81
|
-
pip install faststudio aiosqlite uvicorn # aiosqlite: or asyncpg / aiomysql
|
|
82
|
+
pip install faststudio aiosqlite uvicorn # aiosqlite: or asyncpg / "aiomysql[rsa]>=0.3"
|
|
82
83
|
```
|
|
83
84
|
|
|
85
|
+
Tested in CI with SQLite (Python 3.11–3.13, `aiosqlite`), PostgreSQL 17
|
|
86
|
+
(`asyncpg`) and MySQL 8.4 LTS (`aiomysql[rsa]`); see
|
|
87
|
+
[Databases](https://github.com/bekzod818/faststudio/blob/main/docs/configuration.md#databases).
|
|
88
|
+
|
|
84
89
|
Save as `main.py`:
|
|
85
90
|
|
|
86
91
|
```python
|
|
@@ -119,48 +124,21 @@ class UserAdmin(ModelAdmin, model=User):
|
|
|
119
124
|
search_fields = ["username", "email"]
|
|
120
125
|
list_filter = ["is_active", "is_admin"]
|
|
121
126
|
exclude = ["password_hash"] # never show or accept credentials
|
|
122
|
-
can_create = False # accounts are created
|
|
123
|
-
```
|
|
127
|
+
can_create = False # accounts are created with `faststudio createadmin`
|
|
124
128
|
|
|
125
|
-
Save as `create_admin.py` (creates the table and your first admin; run it once
|
|
126
|
-
per account, since usernames are unique):
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
from sqlalchemy.ext.asyncio import async_sessionmaker
|
|
133
|
-
|
|
134
|
-
from faststudio import hash_password
|
|
135
|
-
from main import Base, User, engine
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
async def create_admin() -> None:
|
|
139
|
-
try:
|
|
140
|
-
async with engine.begin() as conn:
|
|
141
|
-
await conn.run_sync(Base.metadata.create_all)
|
|
142
|
-
async with async_sessionmaker(engine)() as session:
|
|
143
|
-
session.add(
|
|
144
|
-
User(
|
|
145
|
-
username=input("Username: "),
|
|
146
|
-
email=input("Email: "),
|
|
147
|
-
password_hash=hash_password(getpass.getpass("Password: ")),
|
|
148
|
-
is_admin=True,
|
|
149
|
-
)
|
|
150
|
-
)
|
|
151
|
-
await session.commit()
|
|
152
|
-
finally:
|
|
153
|
-
await engine.dispose()
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
asyncio.run(create_admin())
|
|
130
|
+
async def create_tables() -> None: # in a real project, use your migrations
|
|
131
|
+
async with engine.begin() as conn:
|
|
132
|
+
await conn.run_sync(Base.metadata.create_all)
|
|
133
|
+
await engine.dispose()
|
|
157
134
|
```
|
|
158
135
|
|
|
159
|
-
Then:
|
|
136
|
+
Then create the table and your first admin, and start the app:
|
|
160
137
|
|
|
161
138
|
```bash
|
|
162
139
|
export FASTSTUDIO_SECRET_KEY="$(python -c 'import secrets; print(secrets.token_urlsafe(48))')"
|
|
163
|
-
python
|
|
140
|
+
python -c "import asyncio, main; asyncio.run(main.create_tables())"
|
|
141
|
+
faststudio createadmin --app main:admin # asks for the username, email and password
|
|
164
142
|
uvicorn main:app
|
|
165
143
|
# open http://127.0.0.1:8000/admin
|
|
166
144
|
```
|
|
@@ -170,8 +148,8 @@ step, and [`examples/basic`](https://github.com/bekzod818/faststudio/blob/main/e
|
|
|
170
148
|
app covering every field type:
|
|
171
149
|
|
|
172
150
|
<p align="center">
|
|
173
|
-
<img alt="Editing a product: typed inputs, a related-record picker and a JSON field" src="https://raw.githubusercontent.com/bekzod818/faststudio/
|
|
174
|
-
<img alt="The products list in dark mode with an active filter" src="https://raw.githubusercontent.com/bekzod818/faststudio/
|
|
151
|
+
<img alt="Editing a product: typed inputs, a related-record picker and a JSON field" src="https://raw.githubusercontent.com/bekzod818/faststudio/main/docs/assets/screenshot-form.png" width="420">
|
|
152
|
+
<img alt="The products list in dark mode with an active filter" src="https://raw.githubusercontent.com/bekzod818/faststudio/main/docs/assets/screenshot-list-dark.png" width="420">
|
|
175
153
|
</p>
|
|
176
154
|
|
|
177
155
|
## Configuration
|
|
@@ -181,11 +159,14 @@ app covering every field type:
|
|
|
181
159
|
| `secret_key` | `FASTSTUDIO_SECRET_KEY` | required | ≥ 32 chars, random. Startup fails if missing or weak. |
|
|
182
160
|
| `base_url` | – | `/admin` | Mount path. The UI works under any path. |
|
|
183
161
|
| `title` | – | `"FastStudio"` | Shown in the header and browser tab. |
|
|
184
|
-
| `session_max_age` | – | 8 hours | Absolute session lifetime. |
|
|
162
|
+
| `session_max_age` | – | 8 hours | Absolute session lifetime (int seconds or `timedelta`). |
|
|
163
|
+
| `session_idle_timeout` | – | off | Also end sessions after this long without a request; active sessions slide. |
|
|
185
164
|
| `secure_cookies` | – | `True` | Chrome and Firefox accept secure cookies on `http://localhost` and `127.0.0.1`; elsewhere serve over HTTPS. |
|
|
186
165
|
| `max_page_size` | – | `100` | Upper bound for any list request and for `ModelAdmin.page_size`. |
|
|
166
|
+
| `max_list_offset` | – | `10_000` | Lists stop paging after this many rows (deep `OFFSET`s are slow); search, filter or sort to reach older rows. |
|
|
187
167
|
| `rate_limiter` | – | in-memory | Use a shared limiter when running several workers. |
|
|
188
168
|
| `show_powered_by` | – | `True` | "Powered by FastStudio" footer. |
|
|
169
|
+
| `sync_permissions_on_startup` | – | `False` | Create missing permissions on the first admin request (backends with a permission schema, e.g. `contrib.auth`); never deletes. |
|
|
189
170
|
|
|
190
171
|
Full reference: [docs/configuration.md](https://github.com/bekzod818/faststudio/blob/main/docs/configuration.md).
|
|
191
172
|
|
|
@@ -233,4 +214,6 @@ the [architecture overview](https://github.com/bekzod818/faststudio/blob/main/do
|
|
|
233
214
|
|
|
234
215
|
## License
|
|
235
216
|
|
|
236
|
-
[MIT](https://github.com/bekzod818/faststudio/blob/main/LICENSE) © 2026 Bekzod
|
|
217
|
+
[MIT](https://github.com/bekzod818/faststudio/blob/main/LICENSE) © 2026 Bekzod. The bundled common-password list comes from
|
|
218
|
+
Dropbox zxcvbn (MIT); see
|
|
219
|
+
[THIRD_PARTY_NOTICES](https://github.com/bekzod818/faststudio/blob/main/THIRD_PARTY_NOTICES).
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<p align="center"><strong>FastStudio</strong></p>
|
|
2
|
+
|
|
3
|
+
<p align="center"><em>A modern, beautiful admin studio for FastAPI.</em></p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://github.com/bekzod818/faststudio/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/bekzod818/faststudio/actions/workflows/ci.yml/badge.svg"></a>
|
|
7
|
+
<a href="https://codecov.io/gh/bekzod818/faststudio"><img alt="Coverage" src="https://codecov.io/gh/bekzod818/faststudio/branch/main/graph/badge.svg"></a>
|
|
8
|
+
<a href="https://pypi.org/project/faststudio/"><img alt="PyPI" src="https://img.shields.io/pypi/v/faststudio"></a>
|
|
9
|
+
<a href="https://pypi.org/project/faststudio/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/faststudio"></a>
|
|
10
|
+
<a href="https://github.com/bekzod818/faststudio/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
|
|
11
|
+
<a href="https://github.com/astral-sh/ruff"><img alt="Code style: ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
> **Status: alpha.** The public API may change in any `0.x` release until `1.0`.
|
|
15
|
+
|
|
16
|
+
FastStudio adds a polished, Django-Admin-style admin panel to any FastAPI
|
|
17
|
+
application backed by SQLAlchemy 2.0 (async). Register your models with a few
|
|
18
|
+
lines of declarative Python and get a fast React UI for browsing, searching,
|
|
19
|
+
filtering and editing your data. No Node.js required: the UI ships pre-built
|
|
20
|
+
inside the Python wheel.
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img alt="The products list in FastStudio: search, filters, sortable columns and pagination" src="https://raw.githubusercontent.com/bekzod818/faststudio/main/docs/assets/screenshot-list.png" width="860">
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **pip install and go**: the React SPA is bundled in the wheel.
|
|
29
|
+
- **Declarative `ModelAdmin`**: `list_display`, `search_fields`, `list_filter`,
|
|
30
|
+
`ordering`, `readonly_fields`, `exclude`, `can_create` / `can_edit` / `can_delete`.
|
|
31
|
+
- **Schema-driven UI**: tables and forms are generated from your SQLAlchemy
|
|
32
|
+
models. No per-model frontend code.
|
|
33
|
+
- **Server-side everything**: pagination, sorting, search and filters run in
|
|
34
|
+
the database through SQLAlchemy expressions, never string-built SQL.
|
|
35
|
+
- **Secure by default**: argon2 password hashing, signed HTTP-only session
|
|
36
|
+
cookies, CSRF protection, login rate limiting, strict security headers and CSP.
|
|
37
|
+
- **Typed end to end**: `mypy --strict` clean, ships `py.typed`; the
|
|
38
|
+
frontend's API types are generated from the backend's Pydantic contract.
|
|
39
|
+
- Light and dark mode, responsive layout, accessible components.
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install faststudio aiosqlite uvicorn # aiosqlite: or asyncpg / "aiomysql[rsa]>=0.3"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Tested in CI with SQLite (Python 3.11–3.13, `aiosqlite`), PostgreSQL 17
|
|
48
|
+
(`asyncpg`) and MySQL 8.4 LTS (`aiomysql[rsa]`); see
|
|
49
|
+
[Databases](https://github.com/bekzod818/faststudio/blob/main/docs/configuration.md#databases).
|
|
50
|
+
|
|
51
|
+
Save as `main.py`:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from fastapi import FastAPI
|
|
55
|
+
from sqlalchemy import String
|
|
56
|
+
from sqlalchemy.ext.asyncio import create_async_engine
|
|
57
|
+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
58
|
+
|
|
59
|
+
from faststudio import Admin, ModelAdmin, ModelUserBackend
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Base(DeclarativeBase):
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class User(Base): # your own model: FastStudio signs admins in from it
|
|
67
|
+
__tablename__ = "users"
|
|
68
|
+
|
|
69
|
+
id: Mapped[int] = mapped_column(primary_key=True)
|
|
70
|
+
username: Mapped[str] = mapped_column(String(150), unique=True)
|
|
71
|
+
email: Mapped[str] = mapped_column(String(254))
|
|
72
|
+
password_hash: Mapped[str] = mapped_column(String(255))
|
|
73
|
+
is_active: Mapped[bool] = mapped_column(default=True)
|
|
74
|
+
is_admin: Mapped[bool] = mapped_column(default=False)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
engine = create_async_engine("sqlite+aiosqlite:///app.db")
|
|
78
|
+
app = FastAPI()
|
|
79
|
+
# secret_key defaults to the FASTSTUDIO_SECRET_KEY environment variable
|
|
80
|
+
admin = Admin(app, engine=engine, auth_backend=ModelUserBackend(User))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@admin.register
|
|
84
|
+
class UserAdmin(ModelAdmin, model=User):
|
|
85
|
+
list_display = ["id", "username", "email", "is_active", "is_admin"]
|
|
86
|
+
search_fields = ["username", "email"]
|
|
87
|
+
list_filter = ["is_active", "is_admin"]
|
|
88
|
+
exclude = ["password_hash"] # never show or accept credentials
|
|
89
|
+
can_create = False # accounts are created with `faststudio createadmin`
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
async def create_tables() -> None: # in a real project, use your migrations
|
|
93
|
+
async with engine.begin() as conn:
|
|
94
|
+
await conn.run_sync(Base.metadata.create_all)
|
|
95
|
+
await engine.dispose()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then create the table and your first admin, and start the app:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
export FASTSTUDIO_SECRET_KEY="$(python -c 'import secrets; print(secrets.token_urlsafe(48))')"
|
|
102
|
+
python -c "import asyncio, main; asyncio.run(main.create_tables())"
|
|
103
|
+
faststudio createadmin --app main:admin # asks for the username, email and password
|
|
104
|
+
uvicorn main:app
|
|
105
|
+
# open http://127.0.0.1:8000/admin
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The [getting-started guide](https://github.com/bekzod818/faststudio/blob/main/docs/getting-started.md) explains each
|
|
109
|
+
step, and [`examples/basic`](https://github.com/bekzod818/faststudio/blob/main/examples/basic/README.md) is a complete
|
|
110
|
+
app covering every field type:
|
|
111
|
+
|
|
112
|
+
<p align="center">
|
|
113
|
+
<img alt="Editing a product: typed inputs, a related-record picker and a JSON field" src="https://raw.githubusercontent.com/bekzod818/faststudio/main/docs/assets/screenshot-form.png" width="420">
|
|
114
|
+
<img alt="The products list in dark mode with an active filter" src="https://raw.githubusercontent.com/bekzod818/faststudio/main/docs/assets/screenshot-list-dark.png" width="420">
|
|
115
|
+
</p>
|
|
116
|
+
|
|
117
|
+
## Configuration
|
|
118
|
+
|
|
119
|
+
| Option (`Admin(...)`) | Env var | Default | Notes |
|
|
120
|
+
|---|---|---|---|
|
|
121
|
+
| `secret_key` | `FASTSTUDIO_SECRET_KEY` | required | ≥ 32 chars, random. Startup fails if missing or weak. |
|
|
122
|
+
| `base_url` | – | `/admin` | Mount path. The UI works under any path. |
|
|
123
|
+
| `title` | – | `"FastStudio"` | Shown in the header and browser tab. |
|
|
124
|
+
| `session_max_age` | – | 8 hours | Absolute session lifetime (int seconds or `timedelta`). |
|
|
125
|
+
| `session_idle_timeout` | – | off | Also end sessions after this long without a request; active sessions slide. |
|
|
126
|
+
| `secure_cookies` | – | `True` | Chrome and Firefox accept secure cookies on `http://localhost` and `127.0.0.1`; elsewhere serve over HTTPS. |
|
|
127
|
+
| `max_page_size` | – | `100` | Upper bound for any list request and for `ModelAdmin.page_size`. |
|
|
128
|
+
| `max_list_offset` | – | `10_000` | Lists stop paging after this many rows (deep `OFFSET`s are slow); search, filter or sort to reach older rows. |
|
|
129
|
+
| `rate_limiter` | – | in-memory | Use a shared limiter when running several workers. |
|
|
130
|
+
| `show_powered_by` | – | `True` | "Powered by FastStudio" footer. |
|
|
131
|
+
| `sync_permissions_on_startup` | – | `False` | Create missing permissions on the first admin request (backends with a permission schema, e.g. `contrib.auth`); never deletes. |
|
|
132
|
+
|
|
133
|
+
Full reference: [docs/configuration.md](https://github.com/bekzod818/faststudio/blob/main/docs/configuration.md).
|
|
134
|
+
|
|
135
|
+
## Security
|
|
136
|
+
|
|
137
|
+
FastStudio treats the admin as a high-value target. Every API route except
|
|
138
|
+
login requires a session; state-changing requests require a CSRF token; search,
|
|
139
|
+
filter and sort parameters are validated against the fields you declared;
|
|
140
|
+
writes respect `readonly_fields` and `exclude`; logins are throttled per
|
|
141
|
+
account and per client. Run behind a proxy with trusted proxy headers
|
|
142
|
+
(`uvicorn --proxy-headers --forwarded-allow-ips=...`) so client addresses are
|
|
143
|
+
real, and mount the admin on its own subdomain if the host serves untrusted
|
|
144
|
+
content. Read the
|
|
145
|
+
[threat model](https://github.com/bekzod818/faststudio/blob/main/docs/threat-model.md) and report vulnerabilities privately as
|
|
146
|
+
described in [SECURITY.md](https://github.com/bekzod818/faststudio/blob/main/SECURITY.md).
|
|
147
|
+
|
|
148
|
+
## How it compares
|
|
149
|
+
|
|
150
|
+
FastStudio stands on the shoulders of excellent existing projects:
|
|
151
|
+
|
|
152
|
+
- **[SQLAdmin](https://github.com/aminalaee/sqladmin)** is a mature, widely used
|
|
153
|
+
admin for SQLAlchemy built on Starlette with server-rendered Jinja2
|
|
154
|
+
templates. It supports sync and async engines and offers many more features
|
|
155
|
+
than FastStudio does today.
|
|
156
|
+
- **[Starlette-Admin](https://github.com/jowilf/starlette-admin)** is a flexible
|
|
157
|
+
admin framework supporting several ORMs/ODMs (SQLAlchemy, SQLModel,
|
|
158
|
+
MongoEngine, ODMantic, Beanie), with file handling and data export, using
|
|
159
|
+
server-rendered templates.
|
|
160
|
+
|
|
161
|
+
FastStudio takes a different approach: a **single-page React application**
|
|
162
|
+
driven by a versioned JSON metadata contract, with a typed REST API between
|
|
163
|
+
them. It is narrower in scope (SQLAlchemy 2.0 async only) and younger. If you
|
|
164
|
+
need a proven tool today, both projects above are great choices.
|
|
165
|
+
|
|
166
|
+
## Roadmap
|
|
167
|
+
|
|
168
|
+
See [ROADMAP.md](https://github.com/bekzod818/faststudio/blob/main/ROADMAP.md). Highlights after v0.1.0: relationship editing,
|
|
169
|
+
custom actions, file uploads, role-based permissions, audit log, i18n
|
|
170
|
+
(English, Uzbek, Russian).
|
|
171
|
+
|
|
172
|
+
## Contributing
|
|
173
|
+
|
|
174
|
+
Contributions are welcome. Start with [CONTRIBUTING.md](https://github.com/bekzod818/faststudio/blob/main/CONTRIBUTING.md) and
|
|
175
|
+
the [architecture overview](https://github.com/bekzod818/faststudio/blob/main/docs/architecture.md).
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
[MIT](https://github.com/bekzod818/faststudio/blob/main/LICENSE) © 2026 Bekzod. The bundled common-password list comes from
|
|
180
|
+
Dropbox zxcvbn (MIT); see
|
|
181
|
+
[THIRD_PARTY_NOTICES](https://github.com/bekzod818/faststudio/blob/main/THIRD_PARTY_NOTICES).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Third-party notices for FastStudio
|
|
2
|
+
==================================
|
|
3
|
+
|
|
4
|
+
FastStudio is MIT-licensed (see LICENSE). It bundles the following
|
|
5
|
+
third-party material. The same notice ships inside the package at
|
|
6
|
+
faststudio/auth/data/NOTICE.
|
|
7
|
+
|
|
8
|
+
common-passwords.txt.gz
|
|
9
|
+
-----------------------
|
|
10
|
+
Contents: the 20 000 most frequent entries (one password per line, in
|
|
11
|
+
frequency order) of zxcvbn's data/passwords.txt.
|
|
12
|
+
Source: Dropbox zxcvbn, https://github.com/dropbox/zxcvbn
|
|
13
|
+
Version: commit 67c4ece9efc40c9d0a1d7d995b2b22a91be500c2
|
|
14
|
+
(data/passwords.txt, SHA-256
|
|
15
|
+
6313cc5ef683a0461416318ee3b16f3d771a3cd10ea2aae54571d27ff95d951f)
|
|
16
|
+
Licence: MIT (the zxcvbn repository's LICENSE.txt), reproduced below.
|
|
17
|
+
Built by: scripts/build_common_passwords.py (pinned commit and checksum;
|
|
18
|
+
`--check` verifies this file against a fresh build).
|
|
19
|
+
|
|
20
|
+
Provenance note: zxcvbn's README credits "Mark Burnett for releasing his
|
|
21
|
+
10M password corpus", which was reported in 2015 as released to the public
|
|
22
|
+
domain; the zxcvbn repository states no separate licence for its data files,
|
|
23
|
+
which are distributed under the repository's MIT licence. The list contains
|
|
24
|
+
passwords only (no usernames or other personal data).
|
|
25
|
+
|
|
26
|
+
Copyright (c) 2012-2016 Dan Wheeler and Dropbox, Inc.
|
|
27
|
+
|
|
28
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
29
|
+
a copy of this software and associated documentation files (the
|
|
30
|
+
"Software"), to deal in the Software without restriction, including
|
|
31
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
32
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
33
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
34
|
+
the following conditions:
|
|
35
|
+
|
|
36
|
+
The above copyright notice and this permission notice shall be
|
|
37
|
+
included in all copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
40
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
41
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
42
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
43
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
44
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
45
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Example: a small shop back office
|
|
2
2
|
|
|
3
|
-
A FastAPI app with
|
|
4
|
-
tasks) that between them use every field type FastStudio maps: strings,
|
|
5
|
-
integers, decimals, booleans, enums, dates, timezone-aware datetimes,
|
|
6
|
-
UUIDs and
|
|
3
|
+
A FastAPI app with five SQLAlchemy 2.0 models (users, categories, products,
|
|
4
|
+
tasks, tags) that between them use every field type FastStudio maps: strings,
|
|
5
|
+
text, integers, decimals, booleans, enums, dates, timezone-aware datetimes,
|
|
6
|
+
JSON, UUIDs, foreign keys and a many-to-many field. On first start the
|
|
7
|
+
database is filled with demo data.
|
|
7
8
|
|
|
8
9
|
## Run it
|
|
9
10
|
|
|
@@ -16,10 +17,17 @@ uv sync
|
|
|
16
17
|
pnpm -C frontend install && pnpm -C frontend build
|
|
17
18
|
|
|
18
19
|
export FASTSTUDIO_SECRET_KEY="$(python -c 'import secrets; print(secrets.token_urlsafe(48))')"
|
|
19
|
-
uv run python -m examples.basic
|
|
20
|
-
uv run
|
|
20
|
+
uv run python -m examples.basic # first start creates the tables and demo data; Ctrl-C
|
|
21
|
+
uv run faststudio createadmin --app examples.basic.app:create_app --username admin
|
|
22
|
+
uv run python -m examples.basic # http://127.0.0.1:8000/admin
|
|
21
23
|
```
|
|
22
24
|
|
|
25
|
+
The CLI finds the `Admin` mounted on the app that `create_app()` returns.
|
|
26
|
+
`faststudio changepassword admin --app examples.basic.app:create_app` sets a
|
|
27
|
+
new password. To restore a locked-out account (re-enable it, give back admin
|
|
28
|
+
rights and optionally reset its password), use
|
|
29
|
+
`uv run python -m examples.basic.create_admin admin`.
|
|
30
|
+
|
|
23
31
|
`uv run uvicorn examples.basic.app:create_app --factory --reload` works too. The database is
|
|
24
32
|
`./example.db`; set `FASTSTUDIO_EXAMPLE_DATABASE_URL` to use another one
|
|
25
33
|
(any SQLAlchemy async URL, e.g. `postgresql+asyncpg://...`).
|
|
@@ -27,15 +35,19 @@ uv run python -m examples.basic # http://127.0.0.1:8000/ad
|
|
|
27
35
|
## What to look at
|
|
28
36
|
|
|
29
37
|
- `app.py`: one `ModelAdmin` per model. `UserAdmin` excludes the password
|
|
30
|
-
hash and disables creating users from the admin (accounts
|
|
31
|
-
|
|
32
|
-
and page size
|
|
38
|
+
hash and disables creating users from the admin (accounts come from
|
|
39
|
+
`faststudio createadmin`); `ProductAdmin` shows search, filters, default ordering
|
|
40
|
+
and page size; `TaskAdmin` opts its `tags` relationship in with
|
|
41
|
+
`many_to_many` and caps it at 20 tags per task with `many_to_many_limits`.
|
|
42
|
+
- Deleting a tag removes it from every task; the confirmation says how many
|
|
43
|
+
links go.
|
|
33
44
|
- `models.py`: the admin's sign-in uses the app's own `User` model through
|
|
34
45
|
`ModelUserBackend` (`username`, `password_hash`, `is_active`, `is_admin`).
|
|
35
46
|
- Deleting a category that still has products is refused (`409`): FastStudio
|
|
36
47
|
never lets ORM cascades change rows of other models.
|
|
37
48
|
- All admins are equal here: any admin can activate, deactivate, promote or
|
|
38
|
-
delete accounts (including their own; `create_admin` restores
|
|
49
|
+
delete accounts (including their own; `examples.basic.create_admin` restores
|
|
50
|
+
access). For a
|
|
39
51
|
stricter setup add `"is_admin"` and `"is_active"` to `UserAdmin.readonly_fields`.
|
|
40
52
|
- Session cookies are `Secure`. Browsers accept them on `http://127.0.0.1`
|
|
41
53
|
and `http://localhost`; anywhere else, serve the app over HTTPS rather than
|