[Backport v8] Support wildcard values for content scope dimensions - #6292
Draft
VPS-thodax wants to merge 1 commit into
Draft
[Backport v8] Support wildcard values for content scope dimensions#6292VPS-thodax wants to merge 1 commit into
VPS-thodax wants to merge 1 commit into
Conversation
## Problem Content scopes could only grant access to concrete dimension values that are part of `availableContentScopes`. There was no way to grant a user access to any value of a single dimension (e.g. every language within a domain, or every product) without enumerating all values — which is not feasible for dimensions with many (potentially thousands) of values. ## Solution `getContentScopesForUser` can now use the wildcard value "*" as the value of a single content scope dimension to grant access to any value for that dimension. The wildcard is matched during the content scope check, so it does not need to be part of `availableContentScopes`. For users with access to all content scopes, `currentUser.permissions[].contentScopes` now returns a single wildcard scope instead of the enumerated `availableContentScopes`. The default `isAllowed` and `currentUser.allowedContentScopes` handle the wildcard; a custom `isAllowed` must treat "*" as matching any value of a dimension. (cherry picked from commit a00f0b2) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B37BzfVeTSW2Kn9Qgvtd1v
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #6114 to
v8.x.x.Original description
Problem
Content scopes could only grant access to concrete dimension values that are part of
availableContentScopes. There was no way to grant a user access to any value of a single dimension (e.g. every language within a domain, or every product) without enumerating all values — which is not feasible for dimensions with many (potentially thousands) of values.Solution
getContentScopesForUsercan now use the wildcard value"*"as the value of a single content scope dimension to grant access to any value for that dimension. The wildcard is matched during the content scope check, so it does not need to be part ofavailableContentScopes.For users with access to all content scopes,
currentUser.permissions[].contentScopesnow returns a single wildcard scope (e.g.[{ domain: "*", language: "*" }]) instead of the enumeratedavailableContentScopes. The defaultisAllowedandcurrentUser.allowedContentScopeshandle the wildcard; a customisAllowedmust treat"*"as matching any value of a dimension.Backport notes
Cherry-picking the squash commit (
a00f0b2ed6bed7a53b0aad6c5c31f41aa19e1f39) frommainproduced conflicts inpackages/api/cms-api/src/user-permissions/access-control.service.tsandpackages/api/cms-api/src/warnings/warning.resolver.ts, both resolved by applying the incoming change on top ofv8.x.x's existing code (an oldercheckContentScopehelper replaced by the newisScopeWithinhelper, and an import path difference from a laterentity-infodirectory move onmainthat isn't part ofv8.x.x).Verification
@comet/cms-apiand@comet/cms-admin: build, lint (prettier/eslint/tsc) pass.demo/api: lint (api-generator regeneration + prettier/eslint/tsc) passes, generated files unchanged.packages/api/cms-apiunit tests foraccess-control.servicepass.demo/apiAppModuleinitializes correctly viapnpm run console --help(schema/block-meta regenerate); it only fails afterwards on connecting to Postgres, since the full Docker demo could not be started in this sandbox — Docker Hub image pulls are blocked by the environment's network policy (403 from CloudFront).🤖 Generated with Claude Code
https://claude.ai/code/session_01B37BzfVeTSW2Kn9Qgvtd1v
Generated by Claude Code