Repository navigation
refactor(auth): share audit helpers for gateway denials and rejections - #4777
Merged
Merged
Conversation
5 of 6 tasks
TaylorMutch
previously approved these changes
Oct 21, 2026
TaylorMutch
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the complete incremental diff at 1fccc5c against #4762. No actionable findings. Shared denial and rejection helpers preserve status codes, messages, event fields, and protocol labels; refresh auditing uses the router-established request context. CI caveat: x86 Linux failed in sandbox_forward_background_tracks_owned_child_when_pid_discovery_fails because the fake SSH listener encountered AddrInUse. This CLI fixture is outside the changed code; ARM Linux, macOS, and the descendant #4778 checks pass. No local tests run.
2 tasks
Handlers recorded each refusal by emitting an OCSF event and then building the status by hand, so a new refusal could skip the event. These helpers do both in one call: - audit::deny emits an authorization denial for the current request and returns the permission-denied status. Guards, workspace authorization, and the token and current-user handlers use it. - audit::reject_credential emits an Authentication failure for a credential a handler verifies itself and returns the rejection's status. It replaces emit_credential_failure for SSH session tokens and IssueSandboxToken. RefreshSandboxToken now takes its path and origin from the request scope, as every other handler does, instead of rebuilding them from the request. - Failure and logon events share one Authentication builder. - AuthMechanism and AuthFailureReason carry their audit labels. The logon digest uses the label instead of the variant's Debug name. Events and statuses are unchanged. Refs #2912 Signed-off-by: Kris Hicks <khicks@nvidia.com>
krishicks
force-pushed
the
refactor/2912-audit-helpers/krishicks
branch
from
October 21, 2026 14:45
1fccc5c to
d2790eb
Compare
5 of 6 tasks
TaylorMutch
approved these changes
Oct 21, 2026
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
Gateway handlers now record each refusal and build its status in one call, so a refusal can no longer reach the caller without its OCSF event, or carry an event that disagrees with the status:
audit::denyemits an authorization denial and returns the permission-denied status.audit::reject_credentialemits an Authentication failure for a credential a handler verifies itself and returns the rejection's status.emit_*call with a hand-built status. Nothing kept the two together, and the feat(auth): emit structured gateway authentication and authorization events #2912 PRs added about twenty such pairs.Callers receive the same status codes and messages, and the events are unchanged.
Related Issue
Refs #2912
This is a follow-up refactor for #2912 and does not close it. Stacked on #4762.
Changes
audit::denyreplaces emit-then-refuse in the sandbox guards, workspace authorization, workspace role assignment, mutation admission, and theGetCurrentUser,IssueSandboxToken, andRefreshSandboxTokenhandlers. Three sites keep the separate calls because they emit conditionally or reuse a status built elsewhere.audit::reject_credentialreplacesemit_credential_failurefor SSH session tokens andIssueSandboxToken's runtime-identity checks.RefreshSandboxTokennow takes its path and origin from the request scope that the router sets for every authenticated call, as the other handlers do, instead of rebuilding them from the request.AuthMechanism::as_strandAuthFailureReason::as_strreplace the mapping functions inaudit.rs. The logon record keys on the mechanism's label instead of itsDebugname; it is in-memory only, so nothing persisted changes.Testing
cargo nextest run -p openshell-server: all 2,397 tests pass.cargo clippy -p openshell-server --all-targets -- -D warningsChecklist