Add granular PAT support for security policy GraphQL types
Summary
Granular PAT (Personal Access Token) authorization does not currently work for security policy GraphQL types (e.g., OrchestrationPolicyType, PipelineExecutionSchedulePolicyType).
Problem
There are two issues preventing granular PAT authorization:
1. Cross-boundary authorization
Queries like project(fullPath:...).pipelineExecutionSchedulePolicies.upcomingSchedules require permissions on two different boundaries:
:read_projecton the target project:read_pipeline_execution_project_scheduleon thepolicy_management_project
2. Hash-based GraphQL objects
Security policy types represent policies as hashes rather than ActiveRecord models. When adding authorize_granular_token with boundary: :security_policy_management_project, the BoundaryExtractor fails because:
security_policy_management_projectisn't inVALID_BOUNDARY_ACCESSOR_METHODS(only allowsproject,group,itself,owner)- Even if added, the extractor calls
obj.public_send(:security_policy_management_project)on the unwrapped hash, which doesn't have this method
The policy hash structure is:
{
name: "...",
config: <Security::OrchestrationPolicyConfiguration>, # Has the project reference
type: "pipeline_execution_schedule_policy",
...
}Proposed Solutions
- Add
security_policy_management_projecttoVALID_BOUNDARY_ACCESSOR_METHODSinBoundaryExtractor - Modify boundary extraction to check the GraphQL type wrapper (which has the method) before unwrapping to the hash
- OR refactor security policy types to use model-backed presenter objects instead of raw hashes
Related
- MR: !238114 (merged)
- File:
lib/gitlab/graphql/authz/boundary_extractor.rb - File:
ee/app/graphql/types/security_orchestration/orchestration_policy_type.rb
Edited by 🤖 GitLab Bot 🤖