Package org.apache.druid.query.policy
Interface PolicyEnforcer
- All Known Implementing Classes:
NoopPolicyEnforcer,RestrictAllTablesPolicyEnforcer
public interface PolicyEnforcer
Interface for enforcing policies on data sources and segments in Druid queries.
Note: The PolicyEnforcer is intended to serve as a sanity checker and not as a primary authorization mechanism.
It should not be used to implement security rules. Instead, it acts as a last line of defense to verify that
security policies have been implemented correctly and to prevent incorrect policy usage.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the policy complies with the policy enforcer.default voidvalidateOrElseThrow(TableDataSource ds, Policy policy) Validates aDataSourceagainst the policy enforcer.default voidvalidateOrElseThrow(Segment segment, Policy policy) Validates aSegmentagainst the policy enforcer.
-
Method Details
-
validateOrElseThrow
Validates aDataSourceagainst the policy enforcer. Prior to query execution, theQuery.getDataSource()tree is walked. This method is invoked once for eachRestrictedDataSourceand once for eachTableDataSourcethat is not wrapped inside aRestrictedDataSource, no matter where they appear within the tree.- Parameters:
ds- the table to validate.policy- the policy attached to the table; eitherRestrictedDataSource.policyor null.- Throws:
DruidException- if the data source does not comply with the policy
-
validateOrElseThrow
Validates aSegmentagainst the policy enforcer. Prior to query execution, theSegmenttree is walked. This method is invoked once for eachRestrictedSegmentand once for eachReferenceCountedSegmentProviderthat is not wrapped inside aRestrictedSegment.Direct invocation of this method is discouraged; use
Segment.validateOrElseThrow(PolicyEnforcer)instead.- Parameters:
segment- the segment to validatepolicy- the policy on the segment,RestrictedSegment.policyor null for other- Throws:
DruidException- if the segment does not comply with the policy
-
validate
Returns true if the policy complies with the policy enforcer.
-