feat(auth): Prüfwerk access for the RBAC step 4 roles (#989) (#990)
CI / Check (push) Skipped
CI / Agent integration (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Successful in 1m11s
CI / Deploy MCP (push) Successful in 4m54s
CI / Deploy Dashboard (push) Successful in 7m12s
CI / Deploy Agent (push) Successful in 9m1s

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 <noreply@anthropic.com>
This commit was merged in pull request #990.
This commit is contained in:
sharangandClaude Opus 5.5 committed 2026-11-12 10:24:59 +00:00
1 parent 867453b63e
commit ea1b48dd37
8 files changed
+97 -28

No files matched your search

+4 -3
View File
@@ -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"}`.
//!
@@ -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<TenantContext> {
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),
+58 -13
View File
@@ -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),
+5 -4
View File
@@ -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",
@@ -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,
}
+3 -3
View File
@@ -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.
+3 -3
View File
@@ -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.
+2 -1
View File
@@ -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)).