Repository navigation
Let an operation grant admit callers who aren't signed in #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
habdelra
merged 3 commits into
main
from
cs-13533-policy-compile-a-grants-anonymous-opt-in-and-acting-user-key
Oct 6, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ import { | |
| import PolicyPredicateField from '@cardstack/catalog/fields/policy-predicate/policy-predicate'; | ||
| import { subscribeToRealm } from '@cardstack/runtime-common'; | ||
| import StringField from 'https://cardstack.com/base/string'; | ||
| import BooleanField from 'https://cardstack.com/base/boolean'; | ||
| import { | ||
| BoxelInput, | ||
| Button, | ||
|
|
@@ -59,6 +60,22 @@ export class OperationGrant extends FieldDef { | |
| // A BXL boolean expression over the caller and the target. Absent means | ||
| // the grant is unconditional. | ||
| @field where = contains(PolicyPredicateField); | ||
| // Whether the grant also admits a caller who isn't signed in. Off, it | ||
| // admits only signed-in callers, so a grant written before anonymous | ||
| // callers could reach a policy never starts admitting them. Only a grant on | ||
| // a base operation under its own name (`read`, `update`, …) may set it, not | ||
| // one on a custom operation or a named query. The realm doesn't evaluate a | ||
| // `where` that reads `actor()` for such a caller, so a grant whose `where` | ||
| // does never admits one: an anonymous grant is scoped by what the target | ||
| // holds. How hard anonymous callers may use the realm, and which addresses | ||
| // it refuses, are the governed realm's own settings, not the policy's. | ||
| @field anonymous = contains(BooleanField); | ||
| // For an anonymous grant on a write: the key, exactly as written, in the | ||
| // governed realm's `realm.json` settings, whose value is the user the write | ||
| // is made as. The realm names the user rather than the policy, because the | ||
| // policy can live in another realm and its writers must not decide whose | ||
| // identity this realm's writes carry. | ||
| @field actingUser = contains(StringField); | ||
|
|
||
| static embedded = class Embedded extends Component<typeof OperationGrant> { | ||
| <template> | ||
|
|
@@ -74,6 +91,18 @@ export class OperationGrant extends FieldDef { | |
| always | ||
| </span> | ||
| {{/if}} | ||
| {{#if @model.anonymous}} | ||
| <Pill data-test-operation-grant-anonymous> | ||
| anyone | ||
| </Pill> | ||
| {{#if @model.actingUser}} | ||
| <span class='keyword'>as</span> | ||
| <code | ||
| class='acting-user' | ||
| data-test-operation-grant-acting-user | ||
| >config.{{@model.actingUser}}</code> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Claude Code 🤖] Fixed on the compiler side (cardstack/boxel f87ad865fa). It no longer trims |
||
| {{/if}} | ||
| {{/if}} | ||
| </div> | ||
| <style scoped> | ||
| .operation-grant { | ||
|
|
@@ -91,6 +120,10 @@ export class OperationGrant extends FieldDef { | |
| font-size: var(--boxel-font-size-sm); | ||
| color: var(--muted-foreground, var(--boxel-450)); | ||
| } | ||
| .acting-user { | ||
| font-family: var(--boxel-monospace-font-family, monospace); | ||
| font-size: var(--boxel-font-size-sm); | ||
| } | ||
| </style> | ||
| </template> | ||
| }; | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Claude Code 🤖] Added in cardstack/boxel f87ad865fa.
packages/host/tests/integration/realm-policy-test.gtshas a test that renders a policy with an anonymous read, an anonymous write withactingUser, and a signed-in-only grant. It checks the "anyone" pill on exactly the two opted-in grants, andconfig.feedbackWriteron the write alone.