Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## stuart/con-329-projects #5239 +/- ##
=========================================================
Coverage ? 91.5%
=========================================================
Files ? 467
Lines ? 23627
Branches ? 0
=========================================================
Hits ? 21613
Misses ? 2014
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stuartc
force-pushed
the
stuart/con-331-con-334-credentials-collections
branch
from
October 12, 2026 14:25
bc9ce4c to
a64781c
Compare
… add Lightning.Actor for the person or service account a context function records
…:id, recording who created or changed it
…t with credentials:write
…n or a service account with collections:write
…er's grants, instance role and MFA status
stuartc
force-pushed
the
stuart/con-331-con-334-credentials-collections
branch
from
October 12, 2026 14:33
a64781c to
3a2c84f
Compare
4 of 7 tasks
stuartc
removed this pull request from stack #5240
October 12, 2026 14:35
… query per request, not one or more per project
…s whose credentials the caller may list
…ng project, so a service account without it is refused
… repo connection holds it
… an edit that only deletes one is no longer silent
…ed audit write with a 500 rather than a crash
…th 422, as PUT does, rather than 403
This branch has not been deployed
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.
Description
Adds idempotent
PUTandGETendpoints for projects, credentials and collections, open to a person's token or the service account, and moves every decision about who may call them into the policies. It's the Lightning side of jig's apply for CON-329 (projects), CON-331 (credentials) and CON-334 (collections). The API contract is ADR 0024 in the jig repo. It replaces #5238, which this stacked on.The new endpoints:
PUT /api/projects/:idcreates a project under a client-chosen id or replaces its name, description and members;GETis open to the service account too.PUTandGET /api/credentials/:id. A service account names the owner by email; a person can only name themselves. Project links are only ever added.PUTandGET /api/projects/:project_id/collections/:id.projects:write,credentials:writeandcollections:write. Sending the same body twice changes nothing and writes no audit event.How authorisation works now (see
SERVICE_ACCOUNTS.md):Lightning.Scope(replacingLightning.Projects.Scope) describes the caller: actor, grants, instance role, MFA status and, once a project is involved, facts about it such as being scheduled for deletion.insufficient_scope, no standing is 403, and only a caller who would otherwise be allowed hears 409scheduled_for_deletion. That now includes/api/provision.AuthorizeActionplug, before any body parse or lookup.Lightning.Actor: a user or the service account) in the audit trail. Projects, credentials and collections are covered.Commits
Each commit compiles on its own, so it reads well commit by commit:
Lightning.ActorBehaviour changes for existing callers
scopeis refused with 400invalid_scopeinstead of getting every scope.GET /api/projects/:idrefusals are 403, not 401.PUTgives 409; the LiveView form from a stale page too). Scheduling one again is refused. "Delete now" and the purge still work.insufficient_scopewith aWWW-Authenticateheader on the new APIs, and on their own project's older read routes (was 401).:access_projecton it. Show and PUT still list every link id.updatedevent.update_collectionno longer castsproject_id, so the superuser edit modal can't move a collection between projects.Validation steps
mix test test/lightning_web/controllers/api test/lightning/policies test/lightning/scope_test.exsSERVICE_ACCOUNT_PUBLIC_KEYset, get a token withscope=projects:write credentials:write collections:write, thenPUTa project, a credential and a collection twice with the same body. Expect 201 then 200, and no second audit event.scripts/e2e.shagainst this branch runs the lot end to end.Additional notes for the reviewer
Needs a deliberate yes:
credentials:writea service account can create a credential owned by any user and link it to any project (ADR 0022). The 409id_takenon an owner mismatch is what stops it rewriting someone else's credential.DELETEof a scheduled credential still deletes it at once, as today.Follow-ups are in Linear: CON-357 (remaining policies onto Scope), CON-358 (kit's 409 message), CON-359 (contexts take a Scope, plus a Credo check).
No CHANGELOG entry yet; I'll write those just before merge.
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code):owner,:admin,:editor,:viewer)