Skip to content

Grant a private resource to an environment - #11

Merged
vitramir merged 1 commit into
mainfrom
private-resource-environment-grants
Aug 10, 2026
Merged

Grant a private resource to an environment#11
vitramir merged 1 commit into
mainfrom
private-resource-environment-grants

Conversation

@vitramir

Copy link
Copy Markdown
Contributor

Depends on agynio/api#184. Spec: agynio/architecture#178.

A sandbox workload matches no existing principal type. It carries no agent-<id> attribute — there is no agent class behind it — and it cannot be a group member, because groups collect users, agents, and apps. Nothing in the access model could name the engineer at a sandbox shell.

An environment principal resolves to every workload running that environment, agent workloads and sandboxes alike.

No new OpenZiti mechanism

The dial policy names environment-<id>, which the Orchestrator already stamps on every workload identity it creates and which egress rule attachments already target. Same per-resource service, same per-grant policy, same reconciliation, same ≤15s propagation. A workload already running picks the grant up on its next service-list poll without restarting, because the attribute predates the policy.

What had to branch

An environment is a configuration resource, not an identity, so it is not in the Identity registry:

  • Existence and organization resolve through Agents.GetEnvironment instead of Identity.GetIdentityType. The call forwards the caller for the same reason the group lookup does — Agents authorizes environment reads against them.
  • AGENTS_GRPC_TARGET joins the dependency set. WithAgentsClient keeps the existing constructors' signatures, since every other principal resolves without it.
  • Authorization is can_edit_config on the environment — what an egress rule attachment to an environment already requires, and what the agent principal uses on its agent. Not organization owner: a grant here reaches anyone holding can_use, because they can start a sandbox and a sandbox is a shell. It adds a destination to what a shell there already reaches rather than widening who is standing in front of it. There is a test asserting org-owner alone is not enough.

Migration

ALTER TYPE ... ADD VALUE IF NOT EXISTS. The runner applies pending migrations in one transaction and PostgreSQL forbids using an enum value in the transaction that added it — the file says so for whoever adds the next one.

Note for the author

This branch was cut while internal/server/{provisioning,reconciliation,materialization_test}.go had uncommitted work in the tree (the ReturnExisting / keep-Ziti-IDs-on-failed-reprovision change). Only my hunk of provisioning.go is staged here — the environment case in principalRoleAttribute. That work is untouched and still sits unstaged locally.

A sandbox workload matches no existing principal type. It carries no agent-<id>
attribute -- there is no agent class behind it -- and it cannot be a group
member, because groups collect users, agents, and apps. Nothing in the access
model could name the engineer at a sandbox shell.

An environment principal resolves to every workload running that environment,
agent workloads and sandboxes alike. Its dial policy names environment-<id>,
which the Orchestrator already stamps on every workload identity it creates and
which egress rule attachments already target -- so no new OpenZiti mechanism is
involved and nothing about the topology changes.

The two per-principal steps that assume an identity now branch. An environment
is a configuration resource and is not in the Identity registry, so existence
and organization resolve through Agents.GetEnvironment; the call forwards the
caller for the same reason the group lookup does. AGENTS_GRPC_TARGET joins the
dependency set, and WithAgentsClient keeps the existing constructors' shapes
since every other principal resolves without it.

Authorization is can_edit_config on the environment, matching what an egress
rule attachment to an environment already requires and what the agent principal
uses on its agent. Not organization owner: a grant here reaches anyone holding
can_use, because they can start a sandbox and a sandbox is a shell -- it adds a
destination to what a shell there already reaches rather than widening who
stands in front of it.

The enum gains its value by ALTER TYPE. The runner applies pending migrations in
one transaction and PostgreSQL forbids using an enum value in the transaction
that added it, so the file says as much for whoever adds the next one.
@vitramir
vitramir merged commit ff6f003 into main Aug 10, 2026
1 of 2 checks passed
@vitramir
vitramir deleted the private-resource-environment-grants branch August 10, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant