diff --git a/compliance-agent/src/api/handlers/git_source.rs b/compliance-agent/src/api/handlers/git_source.rs index 3355abe..17f598d 100644 --- a/compliance-agent/src/api/handlers/git_source.rs +++ b/compliance-agent/src/api/handlers/git_source.rs @@ -6,15 +6,15 @@ use axum::http::StatusCode; use axum::Json; use compliance_core::models::GitSourceView; -use compliance_core::tenant::OrgRole; use compliance_core::tenant_ctx::TenantCtx; use super::dto::{tenant_db, AgentExt}; use super::ApiResponse; -/// Whether the caller may see the git source: IT administrators and support. +/// Whether the caller may see the git source: administrators (IT_ADMIN, +/// OWNER) and support. fn may_view(tenant: &TenantCtx) -> bool { - tenant.0.staff.is_some() || tenant.0.org_roles.contains(&OrgRole::ItAdmin) + tenant.0.staff.is_some() || tenant.0.is_admin() } /// The source without secrets, plus the webhook URL; `data: null` when the diff --git a/compliance-agent/src/api/handlers/licenses.rs b/compliance-agent/src/api/handlers/licenses.rs index d0dc8f8..af808b4 100644 --- a/compliance-agent/src/api/handlers/licenses.rs +++ b/compliance-agent/src/api/handlers/licenses.rs @@ -292,12 +292,12 @@ pub async fn withdraw( } /// Whether the requester may change the policy and decide reviews: LEGAL, -/// IT_ADMIN, or BreakPilot support. USER confirms licences but does not +/// an administrator (IT_ADMIN, OWNER), or BreakPilot support. USER confirms licences but does not /// decide whether they may be used. fn may_decide(tenant: &TenantCtx) -> bool { let ctx = &tenant.0; ctx.api_key.is_none() - && (ctx.staff.is_some() || ctx.has_any_role(&[OrgRole::Legal, OrgRole::ItAdmin])) + && (ctx.staff.is_some() || ctx.is_admin() || ctx.has_any_role(&[OrgRole::Legal])) } fn refuse_role() -> Refusal { @@ -306,7 +306,7 @@ fn refuse_role() -> Refusal { Json(serde_json::json!({ "error": crate::api::role_gate::FORBIDDEN_ROLE, "access": "read_only", - "needs": ["LEGAL", "IT_ADMIN"], + "needs": ["LEGAL", "IT_ADMIN", "OWNER"], })), ) } @@ -912,6 +912,7 @@ mod tests { fn legal_and_it_admin_decide_users_do_not() { assert!(may_decide(&with_roles(vec![OrgRole::Legal]))); assert!(may_decide(&with_roles(vec![OrgRole::ItAdmin]))); + assert!(may_decide(&with_roles(vec![OrgRole::Owner]))); assert!(!may_decide(&with_roles(vec![OrgRole::User]))); assert!(!may_decide(&with_roles(vec![OrgRole::Cxo]))); } diff --git a/compliance-agent/src/api/handlers/manual_findings.rs b/compliance-agent/src/api/handlers/manual_findings.rs index 72dc261..5c4a9f8 100644 --- a/compliance-agent/src/api/handlers/manual_findings.rs +++ b/compliance-agent/src/api/handlers/manual_findings.rs @@ -4,7 +4,7 @@ //! //! Writing findings into a tenant's record is an administrator's action: the //! tester is given an account in the customer's organisation with the -//! `IT_ADMIN` role. +//! `IT_ADMIN` (or `OWNER`) role. use std::sync::Arc; @@ -16,7 +16,6 @@ use mongodb::bson::{doc, oid::ObjectId}; use serde::{Deserialize, Serialize}; use compliance_core::models::{Finding, ScanType}; -use compliance_core::tenant::OrgRole; use compliance_core::tenant_ctx::TenantCtx; use super::dto::tenant_db; @@ -84,9 +83,10 @@ pub struct ImportSummary { pub duplicates: usize, } -/// Only an organisation's IT administrator writes findings by hand. +/// Only an organisation's administrator (IT_ADMIN, OWNER) writes findings by +/// hand. fn require_admin(tenant: &TenantCtx) -> Result<(), StatusCode> { - if tenant.0.org_roles.contains(&OrgRole::ItAdmin) { + if tenant.0.is_admin() { Ok(()) } else { Err(StatusCode::FORBIDDEN) @@ -221,7 +221,7 @@ pub async fn import_findings( #[cfg(test)] mod tests { use super::*; - use compliance_core::tenant::{TenantContext, TenantStatus}; + use compliance_core::tenant::{OrgRole, TenantContext, TenantStatus}; fn tenant(roles: Vec) -> TenantCtx { TenantCtx(TenantContext { @@ -241,6 +241,7 @@ mod tests { #[test] fn only_an_it_admin_writes_findings() { assert_eq!(require_admin(&tenant(vec![OrgRole::ItAdmin])), Ok(())); + assert_eq!(require_admin(&tenant(vec![OrgRole::Owner])), Ok(())); assert_eq!( require_admin(&tenant(vec![OrgRole::User, OrgRole::Cxo])), Err(StatusCode::FORBIDDEN) diff --git a/compliance-agent/src/api/role_gate.rs b/compliance-agent/src/api/role_gate.rs index ee09e87..1fcbdb6 100644 --- a/compliance-agent/src/api/role_gate.rs +++ b/compliance-agent/src/api/role_gate.rs @@ -2,7 +2,7 @@ //! //! One middleware for every tenant-scoped route, so no handler can forget it: //! -//! * `IT_ADMIN`, `USER` — read and write. +//! * `OWNER`, `IT_ADMIN`, `USER` — read and write. //! * `CXO`, `LEGAL` — 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 @@ -18,7 +18,8 @@ //! Werkbank runner and admin APIs (their own token middleware), the health //! check, and support staff who have not chosen a tenant yet. //! -//! Handlers may still be stricter (manual findings stay `IT_ADMIN`-only). +//! Handlers may still be stricter (manual findings stay for administrators: +//! `IT_ADMIN` and `OWNER`). //! //! API keys (tenant-registry ADR 0001) hold no role. They reach only the //! routes in [`KEY_SCOPES`], each with the scope it names; every other route diff --git a/compliance-agent/src/api/role_gate/router_tests.rs b/compliance-agent/src/api/role_gate/router_tests.rs index e181dd0..fbe990f 100644 --- a/compliance-agent/src/api/role_gate/router_tests.rs +++ b/compliance-agent/src/api/role_gate/router_tests.rs @@ -19,6 +19,7 @@ use tower::ServiceExt; /// Who is calling. #[derive(Debug, Clone, Copy)] enum Caller { + Owner, ItAdmin, User, Cxo, @@ -35,6 +36,7 @@ enum Caller { fn ctx(caller: Caller) -> Option { let roles = match caller { + Caller::Owner => vec![OrgRole::Owner], Caller::ItAdmin => vec![OrgRole::ItAdmin], Caller::User => vec![OrgRole::User], Caller::Cxo => vec![OrgRole::Cxo], @@ -196,6 +198,7 @@ fn routes() -> Vec<(Method, String, bool)> { async fn roles_decide_reads_and_writes() { // (caller, may read, may write) let matrix = [ + (Caller::Owner, true, true), (Caller::ItAdmin, true, true), (Caller::User, true, true), (Caller::Cxo, true, false), diff --git a/compliance-core/src/tenant.rs b/compliance-core/src/tenant.rs index d32c67c..d3cf6d6 100644 --- a/compliance-core/src/tenant.rs +++ b/compliance-core/src/tenant.rs @@ -93,6 +93,9 @@ impl std::fmt::Display for TenantStatus { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "UPPERCASE")] pub enum OrgRole { + /// The organisation's owner: in Prüfwerk the same rights as `IT_ADMIN`, + /// as on the rest of the platform. + Owner, ItAdmin, Cxo, Finance, @@ -108,6 +111,7 @@ impl OrgRole { /// `CXO`, etc.). Round-trips with the JSON layer. pub fn parse(s: &str) -> Self { match s { + "OWNER" => OrgRole::Owner, "IT_ADMIN" => OrgRole::ItAdmin, "CXO" => OrgRole::Cxo, "FINANCE" => OrgRole::Finance, @@ -116,12 +120,20 @@ impl OrgRole { _ => OrgRole::Unknown, } } + + /// Whether the role administers the organisation: `IT_ADMIN` or `OWNER`. + /// What only an administrator may do (manual findings, the git source) + /// asks this, not for `IT_ADMIN` alone. + pub fn is_admin(&self) -> bool { + matches!(self, OrgRole::Owner | OrgRole::ItAdmin) + } } /// What an organisation member may do in Prüfwerk, by their org roles /// (decided 2026-09-30): /// -/// * `IT_ADMIN`, `USER` — [`ProductAccess::Full`]: read and write. +/// * `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`]. @@ -145,7 +157,7 @@ impl ProductAccess { pub fn for_roles(roles: &[OrgRole]) -> Self { if roles .iter() - .any(|r| matches!(r, OrgRole::ItAdmin | OrgRole::User)) + .any(|r| r.is_admin() || matches!(r, OrgRole::User)) { Self::Full } else if roles @@ -293,6 +305,11 @@ impl TenantContext { ProductAccess::for_roles(&self.org_roles) } + /// True if the caller holds `IT_ADMIN` or `OWNER`. + pub fn is_admin(&self) -> bool { + self.org_roles.iter().any(OrgRole::is_admin) + } + /// True if the caller holds at least one of the listed roles. pub fn has_any_role(&self, roles: &[OrgRole]) -> bool { self.org_roles.iter().any(|r| roles.contains(r)) @@ -306,6 +323,7 @@ mod tests { #[test] 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("CXO"), OrgRole::Cxo); assert_eq!(OrgRole::parse("USER"), OrgRole::User); } @@ -338,6 +356,7 @@ mod tests { use OrgRole::*; let cases: &[(&[OrgRole], ProductAccess)] = &[ (&[ItAdmin], ProductAccess::Full), + (&[Owner], ProductAccess::Full), (&[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 5cada51..abd9799 100644 --- a/compliance-dashboard/src/i18n/texts.rs +++ b/compliance-dashboard/src/i18n/texts.rs @@ -5043,8 +5043,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 (IT_ADMIN oder USER)", - en: "Licence to be confirmed first (IT_ADMIN or USER)", + de: "Lizenz zuerst bestätigen (OWNER, IT_ADMIN oder USER)", + en: "Licence to be confirmed first (OWNER, IT_ADMIN or USER)", }; pub const IN_TARGETS: Text = Text { de: "in {n} Prüfobjekten", @@ -5143,12 +5143,12 @@ pub mod license_review { en: "Licence policy", }; pub const POLICY_HINT: Text = Text { - de: "Was eine Lizenz braucht, bevor die Komponente verwendet wird. Ändern dürfen LEGAL und IT_ADMIN.", - en: "What a licence needs before the component is used. LEGAL and IT_ADMIN may change it.", + de: "Was eine Lizenz braucht, bevor die Komponente verwendet wird. Ändern dürfen LEGAL, IT_ADMIN und OWNER.", + en: "What a licence needs before the component is used. LEGAL, IT_ADMIN and OWNER may change it.", }; pub const POLICY_READ_ONLY: Text = Text { - de: "Nur LEGAL und IT_ADMIN können die Richtlinie ändern.", - en: "Only LEGAL and IT_ADMIN can change the policy.", + de: "Nur LEGAL, IT_ADMIN und OWNER können die Richtlinie ändern.", + en: "Only LEGAL, IT_ADMIN and OWNER can change the policy.", }; pub const POLICY_CATEGORY: Text = Text { de: "Art der Lizenz", diff --git a/docs/guide/getting-started-en.md b/docs/guide/getting-started-en.md index 0a45cff..086cdbc 100644 --- a/docs/guide/getting-started-en.md +++ b/docs/guide/getting-started-en.md @@ -35,11 +35,11 @@ What you can do in Prüfwerk depends on your role in the workspace: | Role | Prüfwerk | | --- | --- | -| `IT_ADMIN`, `USER` | everything: add targets, run scans, triage findings | +| `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 | -Only `IT_ADMIN` can add or import findings by hand. +Only `IT_ADMIN` and `OWNER` can add or import findings by hand. ## Quick Walkthrough diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 3b97679..04032c0 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -38,7 +38,7 @@ Was Sie in Prüfwerk tun können, hängt von Ihrer Rolle im Arbeitsbereich ab: | Rolle | Prüfwerk | | --- | --- | -| IT-Administration (`IT_ADMIN`), Benutzer (`USER`) | alles: Prüfobjekte anlegen, prüfen, Befunde bewerten | +| 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 | diff --git a/docs/guide/manual-findings.md b/docs/guide/manual-findings.md index cf69cf4..7cf250f 100644 --- a/docs/guide/manual-findings.md +++ b/docs/guide/manual-findings.md @@ -10,7 +10,7 @@ Two ways to add them, both on a target's details under **Targets**: - **Import a report**: a tool's report as a whole, in SARIF 2.1.0 or OWASP ZAP's JSON report. -Only the organisation's administrators (`IT_ADMIN`) can add or import findings. +Only the organisation's administrators (`IT_ADMIN`, `OWNER`) can add or import findings. A tester working for a customer is invited into that customer's organisation with that role. @@ -59,4 +59,4 @@ curl -X POST "$AGENT/api/v1/targets/$TARGET/findings/import?format=sarif&kind=pe `format` is `sarif` or `zap`; `kind` is `pentest` or `dast`. The import answers with `{"total": …, "imported": …, "duplicates": …}`. A document that is not -the named format is refused with 422, and a user without `IT_ADMIN` with 403. +the named format is refused with 422, and a user without `IT_ADMIN` or `OWNER` with 403. diff --git a/docs/guide/sbom.md b/docs/guide/sbom.md index a2aaa1f..f9e4ef9 100644 --- a/docs/guide/sbom.md +++ b/docs/guide/sbom.md @@ -231,7 +231,7 @@ 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 -IT_ADMIN or USER role can confirm the license themselves; CXO and LEGAL can +OWNER, IT_ADMIN or USER role can confirm the license themselves; CXO and LEGAL can read the confirmations (LEGAL decides about them in the [legal review](#license-policy-and-legal-review)). @@ -285,9 +285,9 @@ announced period (60 days unless changed) is listed in advance. The default policy forbids nothing: copyleft, bought and unknown licenses of shipped components need a review, everything else is allowed. Only the -LEGAL and IT_ADMIN roles can change the policy; everyone else can read it. +LEGAL, IT_ADMIN and OWNER roles can change the policy; everyone else can read it. -**The review.** People with the **LEGAL** role (and IT_ADMIN) decide the +**The review.** People with the **LEGAL** role (and IT_ADMIN or OWNER) decide the components *Zur Prüfung*: 1. Click **Freigeben** in a row, or tick several rows and click