9 Commits
Author SHA1 Message Date
Davide Silvestri 5169076065 feat: introduce User-backed workspace identities (#6556)
* feat: introduce User-backed workspace identities

Replaces workspace core.Agent subjects with identities stored as Django
Users, so permissions, execution and attribution use the same record.

- User.objects and WorkspaceUser.objects are human-only; permission and
  identity code opts in through objects_and_identities. is_human and
  is_identity classify a user at runtime.
- Login, tokens, seats, notification recipients, personal views and
  last-admin checks stay human-only. Roles, teams and field grants work
  for identities unchanged.
- Agent applications run as an identity, never as a person. Every shared
  tool rechecks the identity's authority on each call, and MCP refuses a
  tool that skips that boundary.
- Migrations add the profile metadata and index, remove the Agent model
  and delete or clear legacy Agent data: trash entries, role assignments,
  team memberships, integration authorizations and run-as bindings.
- Rename the management API, UI, events and feature flag to identity.

Squashed and rebased onto develop; the previous history is kept on
backup/6556-before-develop-rebase.

* refactor: remove generic subject options endpoint

* refactor: simplify identity selection and Agent run-as options

* feat: distinguish identity notification senders

* fix: restrict identity bindings to identity managers

* docs: record users and identities verification

* fix: restore snapshots as the person restoring

A restore checked the snapshot creator's permission and used the creator
to decide whether an Agent keeps its identity binding. It now checks the
person restoring, passed to the import as `restored_by`. `copied_by` stays
unset on restore, so credential checks keyed on it behave as on develop.

Restoring a snapshot whose creator was deleted works again. The copy rule
for identity bindings covers Agent run-as only; a copied Local Baserow
integration keeps its authorized subject.

* fix: leave settings pages the user may not open

A settings route without a permitted tab rendered an empty page, as the
Identities page did with its feature flag off. It now opens the first
page the user may see.

* fix: renumber the legacy Agent cleanup migrations

Develop added agent 0016 and integrations 0043, so the migrations that
clear legacy Agent run-as bindings and integration authorizations move to
agent 0017 and integrations 0044.

* test(agent): run the trigger self-event test as an identity

The test added on develop created a `core.Agent`, which this branch
removes. It now uses an identity user as the Agent's run-as subject.

* perf: load user types once per batched permission check

* refactor: state the stored subjects in each subject type

* fix: give every user a profile

* fix: keep identity attribution on rows copied in their workspace

* refactor: give people and identities their own subject type

UserSubjectType stays the type both are registered and stored under. It forwards what differs to HumanSubjectType and IdentitySubjectType, so get_specific_type is the only place in subject code that inspects the user type. The registry returns the specific type on request and get_by_model keeps returning the stored type, which never reads the profile.

An identity's membership is checked in one query instead of two.

* fix: keep the roles of identities when a database is duplicated

The role import read subjects through the model's default manager, which only returns people, so duplicating or restoring a database failed when an identity held a role on it. It now resolves the subject through the subject registry.

A subject that no longer exists is skipped instead of failing the whole duplicate or restore.

* refactor: look up a subject type from its content type in one place

* fix: reload a cached token whose profile is incomplete

A token cached by the previous release has a profile without the user type, which reads as not a person, so its requests were refused until the entry expired. The token cache now treats it as a miss, with the check the user cache already used.

* refactor: check the user type once where the check was repeated

The MCP endpoint loader, the personal view permission manager and the identity trash type each asked the same question several times. The rule that an identity is never selected by email moves from the team handler to the identity subject type.

* refactor: leave trashed workspaces out of the identity membership manager

WorkspaceUser.objects_and_identities was named after objects but also returned memberships of trashed workspaces, so callers filtered them by hand. It now follows the existing pair: it leaves trashed workspaces out, and objects_and_identities_and_trash includes them, as objects_and_trash does for people.

* test: state the behaviour of every user type

The table fails when a user type is added and says what has to be decided first. An unknown type is checked to be denied.

* refactor: refuse to say whether a stored user subject is interactive

The answer differs between a person and an identity, so reading it from the stored type would be wrong for one of them. It now raises and points to the specific type.

* refactor: lock the person in membership writes instead of checking the type

Leaving a workspace, removing a member and adding a user lock the user through the people manager, which refuses an identity or an unknown type in the same query. Nothing adds an identity through add_user_to_workspace, so its branch for identities goes. The last admin check compares the membership with the people who are admin, which needs no type check.

* test: leave no rows behind in the legacy authorization migration test

The test left an integration that pointed at a user that didn't exist and a workspace, in the database the migration tests share. Tests that ran after it then failed on the foreign key or on the workspace id. It now uses a real user and empties the two tables.

* docs: describe the subject types and compare the Subject table alternative

ADR 013 is shorter and states that people and identities each have a specific subject type under the stored auth.User type. It compares shared User storage with a Subject table that users and identities would both point to.

* chore: run the legacy run-as cleanup after the agent actions migration

Develop added agent migration 0017, so the cleanup becomes 0018 and depends on it.

* test: leave no rows behind in the legacy agent migration tests

Like the legacy authorization test, these left a workspace in the database the migration tests share, which a later test that creates workspaces with fixed ids collides with.

* fix: write and read the workspace role of an identity in one place

The role assignment API wrote the role of an identity through the membership update of people, which told every member of the workspace about it and stored Builder as MEMBER, while the identities API stored BUILDER and returned the stored value. Both now write through the identity handler, which stores the role like the role of a person, and the role is read with the resolver the workspace members use.

* fix: take no row lock in the membership writes of a person

Leaving a workspace locked the user before the membership while removing or updating a member locks the membership first, so the two could deadlock. The user type never changes and these operations refuse an identity, so the lock protected nothing: they now only check that the user is a person. Leaving no longer locks the admin memberships and removing a member no longer checks for the last admin, as before identities.

* fix: find an identity by its name only in the subject options

The search also matched the email and username, which for an identity hold an internal key, so searching a part of that key returned every identity.

* chore: run the identity migrations after the new ones on develop

Develop added core 0138, integrations 0044 and enterprise 0073, so the identity migrations become core 0139 and 0140, integrations 0045 and enterprise 0074 and depend on them.

* fix: keep the identity of a copied integration only for identity managers

A duplicated application or a restored snapshot kept the identity its Local Baserow integration acts as, without checking the person who made the copy. Restoring a snapshot could so bring back a binding an admin had removed. The copy now keeps the identity only when that person may bind identities, as the Agent application already did, and is otherwise authorized as that person.

* docs: follow the renumbered migrations and the copy rule in the test plan

The test plan named the identity migrations and their tests by their old numbers and still said a copied integration keeps its subject.

* test(agent): run the row trigger tests as an identity

The row trigger tests added on develop created a `core.Agent`, which this
branch removes. They now use an identity user as the Agent's run-as
subject, and the e2e fixture creates it through the identities endpoint.
2026-11-18 08:44:31 +00:00
alamin-br 40b8371c68 chore: improve pre commit performance (#5406)
* chore: improve pre-commit hook trigger and make sure only applies to
staged/unstaged changes.

* docs: update code-quality doc

* docs: improve doc
2026-05-21 15:05:32 +00:00
alamin-br 4373a68e35 chore: integrate pre-commit hooks (#5392)
* chore: integrate pre-commit hooks for backend and frontend code quality enforcement

* fix: uv.lock

* refactor: consolidate pre-commit hooks to use just recipes and add a pre-commit-uninstall command

* docs: document pre-commit branch linting and update pre-commit configuration to increase file size limits and remove serial execution requirements.
2026-05-21 14:16:38 +02:00
Davide Silvestri e25988ea0d chore: switch to uv and justfile (#4369)
* create backend justfile; switch to uv

* Add deploy and dc-deploy recipes to build images

* Add uv.lock for reproducible builds

* CI fixes + improvements

* Reduce build time

* improve CI caching

* Improve exit early conditions

* Set requires_python==3.11.*; add backend/media to gitignore

* Fix all-in-one Dockerfiles and some other fixes

* Introduce frontend justfile + some other useful recipes

* Fix permissions issue with dev containers

* Improve dockerfiles and docs on how to use the dev env

* Fix mjml-email-compiler service

* Update docs + address feedback

* Fix containers healthchecks

* Fix yarn test in dev container

* Minor fixes to docs and justfile attach command

* Address Petr's feedback

* Address additional feedback

* Add changelog entry

* Address feedback: Petr and Przemek

* address feedback + prepare for saas PR

* minor fixes

* Address Bram's feedback 2
2026-01-15 11:22:22 +01:00
Josh Soref 02ab31c8aa Spelling 2022-07-29 09:12:43 +00:00
Nigel Gott d63a944b50 Add black with rename changes needed for black to work nicely with eslint 2021-04-12 10:36:10 +02:00
Nigel Gott 810852778d Small fixes to the development docs. 2021-03-11 14:07:51 +00:00
Keith Axline d44303a6b1 Fixing typos in docs 2020-10-12 09:39:53 +00:00
Bram Wiepjes 89b28d0270 Resolve "Add usage documentation" 2020-07-13 19:10:24 +00:00