Validate the policy configuration. Returns an error if only one of admin/user role is set — either both must be set (RBAC mode) or both empty (auth-only mode).
(&self)
| 43 | /// Returns an error if only one of admin/user role is set — either |
| 44 | /// both must be set (RBAC mode) or both empty (auth-only mode). |
| 45 | pub fn validate(&self) -> Result<(), String> { |
| 46 | let admin_set = !self.admin_role.is_empty(); |
| 47 | let user_set = !self.user_role.is_empty(); |
| 48 | if admin_set != user_set { |
| 49 | return Err(format!( |
| 50 | "OIDC RBAC misconfiguration: admin_role={:?}, user_role={:?}. \ |
| 51 | Either set both roles (RBAC mode) or leave both empty (authentication-only mode).", |
| 52 | self.admin_role, self.user_role, |
| 53 | )); |
| 54 | } |
| 55 | Ok(()) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | impl AuthzPolicy { |
no test coverage detected