feat(auth): per-user sandbox ownership enforcement#18
Merged
Conversation
Add an `auth/ownership.rs` module that stamps an `openshell.ai/owner` label on sandboxes at creation time (from the verified OIDC identity) and gates access on subsequent operations. Key behaviors: - CreateSandbox: strips client-supplied reserved keys, stamps owner - ListSandboxes: injects owner filter into the label selector - Get/Delete/Watch/Exec/SSH/Service handlers: verify caller owns the sandbox before proceeding - Admin bypass: callers with the configured admin role skip ownership - Backward compat: sandboxes without owner label (pre-existing) and anonymous/LocalDev principals (OIDC disabled) are allowed through Addresses kagenti/kagenti#1976 task A. Signed-off-by: Paolo Dettori <paolo@dettori.dev> Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
Break long method chains across multiple lines to satisfy the project's rustfmt configuration. Signed-off-by: Paolo Dettori <paolo@dettori.dev> Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
- Move `use sha2` and `use std::fmt::Write` to module top (items-after-statements) - Add `#![allow(clippy::result_large_err)]` (consistent with other handlers) - Use `let...else` instead of match for early returns (manual-let-else) - Nest or-patterns in require_identity (unnested-or-patterns) - Collapse nested if in revoke_ssh handler (collapsible-if) Signed-off-by: Paolo Dettori <paolo@dettori.dev> Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
80f9e60 to
f2fa5bd
Compare
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.
Summary
Implements Task A from kagenti/kagenti#1976 (per-user sandbox ownership on a shared OpenShell gateway).
auth/ownership.rsmodule with core ownership functions:stamp_owner,check_owner,owner_selector, andsanitize_subjectopenshell.ai/ownerlabel on sandboxes at creation time from the verified OIDC identityDesign Decisions
openshell.ai/state.config.oidc.admin_roleAuthzPolicyTest Plan
ownership.rs(20 tests covering all branches)Addresses kagenti/kagenti#1976
Assisted-By: Claude Code