From 648cf3102d04f7292dce75dc0e9f6713ea53c921 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Thu, 12 Nov 2026 11:02:02 +0100 Subject: [PATCH] =?UTF-8?q?feat(auth):=20Pr=C3=BCfwerk=20access=20for=20th?= =?UTF-8?q?e=20RBAC=20step=204=20roles=20(#989)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Decided 2026-11-12: PSIRT and DEVELOPMENT get full access (they triage findings and run scans); QUALITY, PURCHASING and AUDITOR read only; PRIVACY and EXTERNAL none, as before. Each parses to its own OrgRole. Admin-only actions (manual findings, git source, licence decisions) stay with IT_ADMIN and OWNER; confirming a licence follows full access, so PSIRT and DEVELOPMENT may confirm. Co-Authored-By: Claude Opus 5.5 --- compliance-agent/src/api/role_gate.rs | 7 +- .../src/api/role_gate/router_tests.rs | 21 ++++++ compliance-core/src/tenant.rs | 71 +++++++++++++++---- compliance-dashboard/src/i18n/texts.rs | 9 +-- .../src/infrastructure/sbom.rs | 2 +- docs/guide/getting-started-en.md | 6 +- docs/guide/getting-started.md | 6 +- docs/guide/sbom.md | 3 +- 8 files changed, 97 insertions(+), 28 deletions(-) diff --git a/compliance-agent/src/api/role_gate.rs b/compliance-agent/src/api/role_gate.rs index 1fcbdb6..ec5164e 100644 --- a/compliance-agent/src/api/role_gate.rs +++ b/compliance-agent/src/api/role_gate.rs @@ -2,12 +2,13 @@ //! //! One middleware for every tenant-scoped route, so no handler can forget it: //! -//! * `OWNER`, `IT_ADMIN`, `USER` — read and write. -//! * `CXO`, `LEGAL` — read only: `GET` / `HEAD` / `OPTIONS`, plus the few +//! * `OWNER`, `IT_ADMIN`, `USER`, `PSIRT`, `DEVELOPMENT` — read and write. +//! * `CXO`, `LEGAL`, `QUALITY`, `PURCHASING`, `AUDITOR` — read only: `GET` / `HEAD` / `OPTIONS`, plus the few //! `POST` routes that only read ([`READ_ONLY_POSTS`]). `LEGAL` also //! decides about licences: the licence policy and the legal review //! ([`ROLE_WRITES`], decided 2026-10-15). -//! * `FINANCE`, or none of these roles — nothing; every request is refused. +//! * `FINANCE`, `PRIVACY`, `EXTERNAL`, or none of these roles — nothing; +//! every request is refused. //! //! Refusals are `403 {"error": "forbidden_role", "access": "none" | "read_only"}`. //! diff --git a/compliance-agent/src/api/role_gate/router_tests.rs b/compliance-agent/src/api/role_gate/router_tests.rs index fbe990f..76c7925 100644 --- a/compliance-agent/src/api/role_gate/router_tests.rs +++ b/compliance-agent/src/api/role_gate/router_tests.rs @@ -25,6 +25,13 @@ enum Caller { Cxo, Legal, Finance, + Psirt, + Development, + Quality, + Purchasing, + Auditor, + Privacy, + External, NoRoles, /// BreakPilot support in a customer's tenant (no org roles of its own). Staff, @@ -42,6 +49,13 @@ fn ctx(caller: Caller) -> Option { Caller::Cxo => vec![OrgRole::Cxo], Caller::Legal => vec![OrgRole::Legal], Caller::Finance => vec![OrgRole::Finance], + Caller::Psirt => vec![OrgRole::Psirt], + Caller::Development => vec![OrgRole::Development], + Caller::Quality => vec![OrgRole::Quality], + Caller::Purchasing => vec![OrgRole::Purchasing], + Caller::Auditor => vec![OrgRole::Auditor], + Caller::Privacy => vec![OrgRole::Privacy], + Caller::External => vec![OrgRole::External], Caller::NoRoles | Caller::Staff | Caller::Key(_) => vec![], Caller::Service => return None, }; @@ -204,6 +218,13 @@ async fn roles_decide_reads_and_writes() { (Caller::Cxo, true, false), (Caller::Legal, true, false), (Caller::Finance, false, false), + (Caller::Psirt, true, true), + (Caller::Development, true, true), + (Caller::Quality, true, false), + (Caller::Purchasing, true, false), + (Caller::Auditor, true, false), + (Caller::Privacy, false, false), + (Caller::External, false, false), (Caller::NoRoles, false, false), (Caller::Staff, true, true), (Caller::Service, true, true), diff --git a/compliance-core/src/tenant.rs b/compliance-core/src/tenant.rs index d3cf6d6..67822e4 100644 --- a/compliance-core/src/tenant.rs +++ b/compliance-core/src/tenant.rs @@ -101,6 +101,20 @@ pub enum OrgRole { Finance, Legal, User, + /// Product security (RBAC step 4): full access, triages and scans. + Psirt, + /// Development (RBAC step 4): full access, triages and scans. + Development, + /// Quality (RBAC step 4): read only. + Quality, + /// Privacy (RBAC step 4): no access to Prüfwerk. + Privacy, + /// Purchasing (RBAC step 4): read only. + Purchasing, + /// Auditor (RBAC step 4): read only. + Auditor, + /// External (RBAC step 4): no access to Prüfwerk. + External, /// Anything we haven't enumerated yet — forwards-compatible. #[serde(other)] Unknown, @@ -117,6 +131,13 @@ impl OrgRole { "FINANCE" => OrgRole::Finance, "LEGAL" => OrgRole::Legal, "USER" => OrgRole::User, + "PSIRT" => OrgRole::Psirt, + "DEVELOPMENT" => OrgRole::Development, + "QUALITY" => OrgRole::Quality, + "PRIVACY" => OrgRole::Privacy, + "PURCHASING" => OrgRole::Purchasing, + "AUDITOR" => OrgRole::Auditor, + "EXTERNAL" => OrgRole::External, _ => OrgRole::Unknown, } } @@ -132,11 +153,15 @@ impl OrgRole { /// What an organisation member may do in Prüfwerk, by their org roles /// (decided 2026-09-30): /// -/// * `OWNER`, `IT_ADMIN`, `USER` — [`ProductAccess::Full`]: read and write -/// (`OWNER` added 2026-11-12: it has `IT_ADMIN`'s rights platform-wide). -/// * `CXO`, `LEGAL` — [`ProductAccess::ReadOnly`]: findings, reports, SBOM, -/// evidence and exports, but no change of any kind. -/// * `FINANCE`, or none of these roles — [`ProductAccess::None`]. +/// * `OWNER`, `IT_ADMIN`, `USER`, `PSIRT`, `DEVELOPMENT` — +/// [`ProductAccess::Full`]: read and write (`OWNER` added 2026-11-12: it has +/// `IT_ADMIN`'s rights platform-wide; `PSIRT` and `DEVELOPMENT` from RBAC +/// step 4, decided 2026-11-12). +/// * `CXO`, `LEGAL`, `QUALITY`, `PURCHASING`, `AUDITOR` — +/// [`ProductAccess::ReadOnly`]: findings, reports, SBOM, evidence and +/// exports, but no change of any kind. +/// * `FINANCE`, `PRIVACY`, `EXTERNAL`, or none of these roles — +/// [`ProductAccess::None`]. /// /// The strongest role a user holds wins. BreakPilot support sessions are not /// judged by org roles (see [`TenantContext::product_access`]). @@ -155,15 +180,20 @@ pub enum ProductAccess { impl ProductAccess { /// The access the org `roles` grant. pub fn for_roles(roles: &[OrgRole]) -> Self { - if roles - .iter() - .any(|r| r.is_admin() || matches!(r, OrgRole::User)) - { + if roles.iter().any(|r| { + r.is_admin() || matches!(r, OrgRole::User | OrgRole::Psirt | OrgRole::Development) + }) { Self::Full - } else if roles - .iter() - .any(|r| matches!(r, OrgRole::Cxo | OrgRole::Legal)) - { + } else if roles.iter().any(|r| { + matches!( + r, + OrgRole::Cxo + | OrgRole::Legal + | OrgRole::Quality + | OrgRole::Purchasing + | OrgRole::Auditor + ) + }) { Self::ReadOnly } else { Self::None @@ -324,6 +354,13 @@ mod tests { fn org_role_parses_known_values() { assert_eq!(OrgRole::parse("IT_ADMIN"), OrgRole::ItAdmin); assert_eq!(OrgRole::parse("OWNER"), OrgRole::Owner); + assert_eq!(OrgRole::parse("PSIRT"), OrgRole::Psirt); + assert_eq!(OrgRole::parse("DEVELOPMENT"), OrgRole::Development); + assert_eq!(OrgRole::parse("QUALITY"), OrgRole::Quality); + assert_eq!(OrgRole::parse("PRIVACY"), OrgRole::Privacy); + assert_eq!(OrgRole::parse("PURCHASING"), OrgRole::Purchasing); + assert_eq!(OrgRole::parse("AUDITOR"), OrgRole::Auditor); + assert_eq!(OrgRole::parse("EXTERNAL"), OrgRole::External); assert_eq!(OrgRole::parse("CXO"), OrgRole::Cxo); assert_eq!(OrgRole::parse("USER"), OrgRole::User); } @@ -357,6 +394,14 @@ mod tests { let cases: &[(&[OrgRole], ProductAccess)] = &[ (&[ItAdmin], ProductAccess::Full), (&[Owner], ProductAccess::Full), + (&[Psirt], ProductAccess::Full), + (&[Development], ProductAccess::Full), + (&[Quality], ProductAccess::ReadOnly), + (&[Purchasing], ProductAccess::ReadOnly), + (&[Auditor], ProductAccess::ReadOnly), + (&[Privacy], ProductAccess::None), + (&[External], ProductAccess::None), + (&[External, Auditor], ProductAccess::ReadOnly), (&[User], ProductAccess::Full), (&[Cxo], ProductAccess::ReadOnly), (&[Legal], ProductAccess::ReadOnly), diff --git a/compliance-dashboard/src/i18n/texts.rs b/compliance-dashboard/src/i18n/texts.rs index bf775f8..ce67e1d 100644 --- a/compliance-dashboard/src/i18n/texts.rs +++ b/compliance-dashboard/src/i18n/texts.rs @@ -4732,8 +4732,9 @@ mod run_error_tests { } } -/// What a user's org role allows (`IT_ADMIN` / `USER` everything, `CXO` / -/// `LEGAL` reading, `FINANCE` and no role nothing). +/// What a user's org role allows (`OWNER` / `IT_ADMIN` / `USER` / `PSIRT` / +/// `DEVELOPMENT` everything; `CXO` / `LEGAL` / `QUALITY` / `PURCHASING` / +/// `AUDITOR` reading; `FINANCE`, `PRIVACY`, `EXTERNAL` and no role nothing). pub mod access { use super::Text; @@ -5124,8 +5125,8 @@ pub mod license_review { en: "No licence is known for this component. Confirm its licence first; then it can be approved or rejected.", }; pub const CONFIRM_FIRST_OTHERS: Text = Text { - de: "Lizenz zuerst bestätigen (OWNER, IT_ADMIN oder USER)", - en: "Licence to be confirmed first (OWNER, IT_ADMIN or USER)", + de: "Lizenz zuerst bestätigen (eine Rolle mit Schreibzugriff)", + en: "Licence to be confirmed first (a role that may change data)", }; pub const IN_TARGETS: Text = Text { de: "in {n} Prüfobjekten", diff --git a/compliance-dashboard/src/infrastructure/sbom.rs b/compliance-dashboard/src/infrastructure/sbom.rs index 9c23a9c..3f272a9 100644 --- a/compliance-dashboard/src/infrastructure/sbom.rs +++ b/compliance-dashboard/src/infrastructure/sbom.rs @@ -193,7 +193,7 @@ pub struct LicenseCheckData { /// Whether the requester may decide reviews and change the policy. #[serde(default)] pub may_decide: bool, - /// Whether the requester may confirm licences (IT_ADMIN, USER). + /// Whether the requester may confirm licences (any role with full access). #[serde(default)] pub may_confirm: bool, } diff --git a/docs/guide/getting-started-en.md b/docs/guide/getting-started-en.md index 80a264a..177ff73 100644 --- a/docs/guide/getting-started-en.md +++ b/docs/guide/getting-started-en.md @@ -35,9 +35,9 @@ What you can do in Prüfwerk depends on your role in the workspace: | Role | Prüfwerk | | --- | --- | -| `OWNER`, `IT_ADMIN`, `USER` | everything: add targets, run scans, triage findings | -| `CXO`, `LEGAL` | read only: view and export findings, reports, SBOM, evidence | -| `FINANCE`, or none of these | no access | +| `OWNER`, `IT_ADMIN`, `USER`, `PSIRT`, `DEVELOPMENT` | everything: add targets, run scans, triage findings | +| `CXO`, `LEGAL`, `QUALITY`, `PURCHASING`, `AUDITOR` | read only: view and export findings, reports, SBOM, evidence | +| `FINANCE`, `PRIVACY`, `EXTERNAL`, or none of these | no access | Only `IT_ADMIN` and `OWNER` can add or import findings by hand. diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 9a720ea..28a20b8 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -38,9 +38,9 @@ Was Sie in Prüfwerk tun können, hängt von Ihrer Rolle im Arbeitsbereich ab: | Rolle | Prüfwerk | | --- | --- | -| Inhaber (`OWNER`), IT-Administration (`IT_ADMIN`), Benutzer (`USER`) | alles: Prüfobjekte anlegen, prüfen, Befunde bewerten | -| Geschäftsführung (`CXO`), Recht (`LEGAL`) | nur lesen: Befunde, Berichte, Stückliste, Nachweise ansehen und exportieren | -| Finanzen (`FINANCE`) oder keine dieser Rollen | kein Zugriff | +| Inhaber (`OWNER`), IT-Administration (`IT_ADMIN`), Benutzer (`USER`), Produktsicherheit (`PSIRT`), Entwicklung (`DEVELOPMENT`) | alles: Prüfobjekte anlegen, prüfen, Befunde bewerten | +| Geschäftsführung (`CXO`), Recht (`LEGAL`), Qualität (`QUALITY`), Einkauf (`PURCHASING`), Prüfer (`AUDITOR`) | nur lesen: Befunde, Berichte, Stückliste, Nachweise ansehen und exportieren | +| Finanzen (`FINANCE`), Datenschutz (`PRIVACY`), Extern (`EXTERNAL`) oder keine dieser Rollen | kein Zugriff | Befunde von Hand anlegen oder importieren kann nur die IT-Administration. diff --git a/docs/guide/sbom.md b/docs/guide/sbom.md index 87c0ed5..2aeb43a 100644 --- a/docs/guide/sbom.md +++ b/docs/guide/sbom.md @@ -272,7 +272,8 @@ Copyleft-licensed dependencies can require you to release your source code under ### Confirming a license Where the scan finds no license (**Unknown**) or a wrong one, people with the -OWNER, IT_ADMIN or USER role can confirm the license themselves; CXO and LEGAL can +a role that may change data (OWNER, IT_ADMIN, USER, PSIRT, DEVELOPMENT) can confirm +the license themselves; read-only roles (CXO, LEGAL, QUALITY, PURCHASING, AUDITOR) can read the confirmations (LEGAL decides about them in the [legal review](#license-policy-and-legal-review)).