feat: environments and production-to-staging relations (auth M6b)
- environment (production/staging/development) on source orbits and on restore targets; an unlabelled target fails closed and a production target is refused - directed, versioned relations from a managed source orbit to a restore target: one active relation per pair, retargeting makes a new id and ends the old one - refusals name the rule: unknown or unlabelled source/target, not a managed capture profile, not restore-ready, application or engine mismatch, inactive Outpost, and a target whose identity matches a database captured as production in any snapshot - relations end in the same transaction when their target is relabelled production or an Outpost is revoked; usability is re-read live - refresh.run is granted per relation id in its own table (user or group, expiry), never global, never carried to a new version, and never accepted by the orbit gate - admin API under /api/v1/relations plus environment endpoints; people holding only a relation grant see names and environments, never identity, host, Outpost or application - Relations console; sign-in form without SSO no longer shows a stray "Details" label Tests extend the access matrix with relation fixtures and a caller that holds only a relation grant. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,39 @@ pub(super) fn scoped(state: &HubState, actor: &OperatorActor, permission: Permis
|
||||
if allowed { Ok(()) } else { Err(StatusCode::FORBIDDEN) }
|
||||
}
|
||||
|
||||
/// Use one relation. Administrators always; anyone else only through a live grant on that very relation
|
||||
/// (not on its orbit, not on an older version of it). Everything else answers 404, so a relation's
|
||||
/// existence is not confirmed to someone who cannot use it.
|
||||
#[allow(dead_code)] // used by the refresh run (M6c); the matrix already exercises the list built on the same grants
|
||||
pub(super) fn relation(state: &HubState, actor: &OperatorActor, relation: Uuid) -> Result<(), StatusCode> {
|
||||
let resource = AuditResource::Relation(relation);
|
||||
if actor.subject.admin {
|
||||
return audit(state, actor, resource, true);
|
||||
}
|
||||
let granted = state
|
||||
.db
|
||||
.granted_relations(actor.subject.user_id.as_deref(), &actor.subject.groups, now())
|
||||
.map_err(internal)?;
|
||||
let allowed = granted.iter().any(|id| id == &relation.to_string());
|
||||
audit(state, actor, resource, allowed)?;
|
||||
if allowed { Ok(()) } else { Err(StatusCode::NOT_FOUND) }
|
||||
}
|
||||
|
||||
/// The relations a caller may use: `None` for an administrator (all), otherwise their granted ids.
|
||||
/// A caller with none gets 403 rather than an empty list.
|
||||
pub(super) fn visible_relations(state: &HubState, actor: &OperatorActor) -> Result<Option<Vec<String>>, StatusCode> {
|
||||
if actor.subject.admin {
|
||||
audit(state, actor, AuditResource::Api, true)?;
|
||||
return Ok(None);
|
||||
}
|
||||
let granted = state
|
||||
.db
|
||||
.granted_relations(actor.subject.user_id.as_deref(), &actor.subject.groups, now())
|
||||
.map_err(internal)?;
|
||||
audit(state, actor, AuditResource::Api, !granted.is_empty())?;
|
||||
if granted.is_empty() { Err(StatusCode::FORBIDDEN) } else { Ok(Some(granted)) }
|
||||
}
|
||||
|
||||
/// Which orbits a list may show.
|
||||
pub(super) enum Visible {
|
||||
All,
|
||||
|
||||
Reference in New Issue
Block a user