@@ -31,6 +31,7 @@ class CheckOptions:
3131 subjType : Optional [str ] = ""
3232 subjMapper : Optional [IdentityMapper ] = None
3333 policyPath : Optional [str ] = ""
34+ policyRoot : Optional [str ] = ""
3435 policyPathMapper : Optional [StringMapper ] = None
3536
3637
@@ -110,6 +111,7 @@ def _with_overrides(self, **kwargs: Any) -> "CheckMiddleware":
110111 relationName = kwargs .get ("relation_name" , self ._options .relationName ),
111112 relationMapper = kwargs .get ("relation_mapper" , self ._options .relationMapper ),
112113 policyPath = kwargs .get ("policy_path" , self ._options .policyPath ),
114+ policyRoot = kwargs .get ("policy_root" , self ._options .policyRoot ),
113115 subjMapper = kwargs .get ("identity_provider" , self ._identity_provider ),
114116 objId = kwargs .get ("object_id" , self ._options .objId ),
115117 objType = kwargs .get ("object_type" , self ._options .objType ),
@@ -128,8 +130,9 @@ async def mapper() -> str:
128130 policy_path = await self ._options .policyPathMapper ()
129131 if policy_path == "" :
130132 policy_path = "check"
131- if self ._aserto_middleware ._policy_path_root != "" :
132- policy_path = self ._aserto_middleware ._policy_path_root + "." + policy_path
133+ policy_root = self ._options .policyRoot or self ._aserto_middleware ._policy_path_root
134+ if policy_root :
135+ policy_path = f"{ policy_root } .{ policy_path } "
133136 return policy_path
134137
135138 return mapper
@@ -179,7 +182,7 @@ async def decorated(*args: Any, **kwargs: Any) -> Response:
179182 identity_provider = self ._identity_provider ,
180183 policy_instance_name = self ._aserto_middleware ._policy_instance_name or "" ,
181184 policy_instance_label = self ._aserto_middleware ._policy_instance_label or "" ,
182- policy_path_root = self ._aserto_middleware ._policy_path_root ,
185+ policy_path_root = self ._options . policyRoot or self . _aserto_middleware ._policy_path_root ,
183186 policy_path_resolver = policy_mapper ,
184187 resource_context_provider = resource_context ,
185188 )
0 commit comments