Skip to content

[#15] Add project membership and permissions - #56

Open
usfmah wants to merge 1 commit into
mnemosyne-systems:mainfrom
usfmah:membership-and-permissions
Open

usfmah wants to merge 1 commit into
mnemosyne-systems:mainfrom
usfmah:membership-and-permissions

Conversation

@usfmah

@usfmah usfmah commented Nov 14, 2026

Copy link
Copy Markdown

Closes #15

Problem

Project access relied on global Keycloak roles and Project.ownerSubject. Private projects could not be shared, any lead could build public projects, and authorization logic was duplicated across resources.

Changes

  • Added ProjectMembership with OWNER and MEMBER roles.
  • Project creators are automatically assigned OWNER.
  • Added database constraints for unique memberships and one owner per project.
  • Introduced ProjectAccess to centralize visibility and authorization checks.
  • Leads must be project members to start builds; admins bypass membership checks.
  • Added membership endpoints to list, add, and remove members using Keycloak usernames.
  • Keycloak subject IDs are never exposed; failures return a generic 502.
  • Existing ownerSubject is retained, but authorization relies on membership.

Database

make reset is required. No migration or backfill is provided, as agreed in the issue discussion. Reset deletes local database and Keycloak volumes.

Questions

  1. Should a project support multiple OWNERs, or one OWNER with multiple lead-role members?
  2. Should editing require LEAD + membership as stated in the issue, or LEAD + OWNER as currently implemented?

Private projects can now be shared with members instead of being visible only
to their owner and admins. Access to everything else, from edits to builds,
is decided in one place.

- ProjectAccess centralizes project visibility and permissions; the inline
  copies in ProjectResource, BuildResource and BranchResource are gone
- Starting a build requires the global lead or admin role and membership of
  the project; admins bypass membership
- Membership is backed by a new projectmembership table with exactly one
  OWNER per project (partial unique index); deleting a project cascades and
  creating one records the creator as OWNER
- Membership API GET/POST/DELETE /api/projects/{id}/members[/{username}]
  resolves usernames through Keycloak (cisys-backend service account);
  owners and admins manage members, members and admins list them
- Project membership never grants what the caller's global role forbids;
  subjects are never exposed outside the admin API
- Docs and the global-role x visibility x membership test matrix updated
@jesperpedersen

Copy link
Copy Markdown
Contributor

A project can have multiple leads and multiple members - the OWNER concept is confusing so everything need to clearly explained, or changed. We need to use MEMBER, LEAD or ADMIN

@usfmah

usfmah commented Nov 14, 2026

Copy link
Copy Markdown
Author

@jesperpedersen
Got it. Just to clarify:

  1. Are MEMBER, LEAD, and ADMIN project-level roles, independent of global Keycloak roles? I am still confused between global and project roles
  2. Should creating a project automatically assign the creator as a LEAD?
  3. Do global admins need project membership, or do they retain access to all projects?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Add a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add project membership and permissions

2 participants