Expand description
Authorization helpers: validate user access to HSM groups and their members.
Every service-layer function that takes a node, group, or session label from the caller runs one of these checks before touching the backend. The standard pattern is:
- Resolve the caller’s request to a
Vec<String>of xnames or group labels (often viacrate::service::node_ops). - Call
validate_user_group_members_access(xnames) orvalidate_user_group_vec_access(group labels). - Proceed to the actual backend mutation.
Admin tokens carrying the PA_ADMIN role short-circuit every
check to Ok(()) without touching the backend, mirroring the
“admin sees everything” expectation. Listing endpoints still
validate so the response can’t disclose more than the caller
could have asked for directly.
The short-circuit is centralised in the pub(crate) is_admin
helper so that a future change — e.g. adding audit logging for
admin bypasses, or gating on JWKS verification before skipping
group-scope checks — only needs to touch one place.
Statics§
- PA_
ADMIN - Keycloak role name that grants full admin access. The canonical
definition lives in
manta_shared::common::jwt_ops::PA_ADMIN; this re-export keepsservice::authorization::PA_ADMINcallers compiling after the relocation. Keycloak role name that grants full admin access. Owned here so every workspace crate that decodes JWTs can read it without pullingmanta-serveras a dependency.
Functions§
- require_
admin - Return
Ok(())when the caller carries the admin role (pa_admin);Err(Error::BadRequest(...))otherwise. - validate_
ansible_ limit_ membership_ access - Validate every xname in a comma-separated
ansible_limit-style string against the caller’s accessible groups. - validate_
group_ members_ access - Like
validate_user_group_members_accessbut with the caller-accessible group list supplied explicitly. - validate_
group_ vec_ access - Pure check that every label in
group_target_vecappears ingroup_available_vec. - validate_
user_ group_ access - Validate that
group_nameis in the set this token can access. - validate_
user_ group_ members_ access - Validate that every xname in
group_members_target_vecis a member of at least one group the token can access. - validate_
user_ group_ vec_ access - Validate that every label in
group_vecis in the set the token can access.