Class ControlPlaneAuthorizer
java.lang.Object
org.mockserver.authentication.authorization.ControlPlaneAuthorizer
Coarse, hierarchical authorization for the control plane ("RBAC by standards
conformance"): maps a verified principal's scopes/groups through a configured
value -> role mapping into the set of granted ControlPlaneRoles, then
decides whether those granted roles satisfy the role REQUIRED by an operation.
The required role is the coarse read/mutate split: a read requires ControlPlaneRole.READ; any other (mutating) operation requires ControlPlaneRole.MUTATE. Granted roles are hierarchical, so an ADMIN
scope satisfies everything and a MUTATE scope also satisfies reads.
Fail-closed by construction: a principal with no scopes, or whose scopes map to no role, is granted no roles and is denied every operation. Authorization therefore requires a verified principal whose scopes/groups are mapped — i.e. control-plane OIDC authentication should be enabled alongside it.
Immutable and side-effect free; the enforcement decision (HTTP 403, audit outcome) is the caller's responsibility.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongrantedRoles(Set<String> verifiedScopes) Maps the principal's verified scopes through the configured mapping into the set of granted roles.booleanisAuthorized(Set<String> verifiedScopes, boolean isRead) requiredRole(boolean isRead) The coarse role required for an operation:ControlPlaneRole.READfor a read,ControlPlaneRole.MUTATEfor everything else (a mutation).
-
Constructor Details
-
ControlPlaneAuthorizer
- Parameters:
scopeToRole- mapping from a verified scope/group VALUE to the coarse role it grants; unrecognised roles must already be filtered out by the caller (parsing keeps only read/mutate/admin). May be empty or null (then nothing is ever granted).
-
-
Method Details
-
grantedRoles
Maps the principal's verified scopes through the configured mapping into the set of granted roles. Scopes not present in the mapping contribute nothing. Never null. -
requiredRole
The coarse role required for an operation:ControlPlaneRole.READfor a read,ControlPlaneRole.MUTATEfor everything else (a mutation). -
isAuthorized
- Returns:
- true if the principal's
verifiedScopesgrant a role that satisfies the role required by the operation (read vs mutate). Fail-closed: an empty granted set never satisfies anything.
-