( user: User, project: Project, requiredPermissions: QueryPermission[], bindingExprCheck: (expr?: Expr) => boolean )
| 219 | // policy + roles) via the util bridge — relocated from the deleted Pinia |
| 220 | // `projectIamPolicy` store, whose data was never populated in the React shell. |
| 221 | const checkProjectIAMPolicyWithExpr = ( |
| 222 | user: User, |
| 223 | project: Project, |
| 224 | requiredPermissions: QueryPermission[], |
| 225 | bindingExprCheck: (expr?: Expr) => boolean |
| 226 | ): boolean => { |
| 227 | const policy = appStoreUtilBridge()?.getProjectIamPolicy(project.name); |
| 228 | if (!policy) { |
| 229 | return false; |
| 230 | } |
| 231 | for (const binding of policy.bindings) { |
| 232 | const nameList = getUserListInBinding({ binding, ignoreGroup: false }); |
| 233 | if ( |
| 234 | !nameList.includes(getUserFullNameByType(user)) && |
| 235 | !nameList.includes(`${userNamePrefix}${ALL_USERS_USER_EMAIL}`) |
| 236 | ) { |
| 237 | continue; |
| 238 | } |
| 239 | const permissions = |
| 240 | appStoreUtilBridge()?.getRoleByName(binding.role)?.permissions || []; |
| 241 | for (const permission of permissions) { |
| 242 | if (requiredPermissions.includes(permission as QueryPermission)) { |
| 243 | if (bindingExprCheck(binding.parsedExpr)) { |
| 244 | return true; |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | return false; |
| 250 | }; |
| 251 | |
| 252 | export const checkQuerierPermission = ( |
| 253 | database: Database, |
no test coverage detected