Repository navigation
feat(auth): emit OCSF logon events for accepted gateway credentials - #4761
Conversation
|
🌿 Preview your docs: https://nvidia-preview-pr-4761.docs.buildwithfern.com/openshell |
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. api-behavior — No explicit risk acceptance found
Review details
Advisory review; publication gates are unchanged. |
|
Compatibility review, finding 1 (api-behavior): I accept this breaking change and its consumer risk. Since v0.1.5, I'm not taking the suggested action (opt-in, disabled by default). The reasons:
|
0f39228 to
249ca20
Compare
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. api-behavior — Risk explicitly accepted
Review details
Advisory review; publication gates are unchanged. |
When a gateway replica accepts a credential for the first time, it now emits an Informational OCSF Authentication event with status Success. The caller's request proceeds exactly as before. The event records: - Who: the principal (user, mTLS operator, sandbox, or gateway peer), with the same user types as authorization denials. - How: the authentication protocol (OpenID, mtls, sandbox_jwt, compute_driver, or k8s_service_account). - Where: the gRPC method of the request that logged on. - Correlation: the caller's address and request ID, the same fields the failure and denial events carry. Every gRPC request authenticates, and an idle sandbox's supervisor polls the gateway several times a minute, so an event per request would bury user logons. Each credential therefore logs on once: later requests with the same bearer token or client certificate emit nothing until the credential has been in use for an hour, when it logs on again. The replica's connections share this record, which holds up to 16,384 credentials and forgets the oldest early when a new one arrives while full. It keys on a SHA-256 digest of the credential that authenticated the caller (the bearer token or the client certificate's fingerprint), so headers the authenticator ignored cannot force new logons, and a renewed certificate for the same subject logs on again. Digests stay in memory. Requests admitted by allow_unauthenticated_users, or by a gateway with no authentication configured, emit no success event, since no credential was verified. Refs #2912 Signed-off-by: Kris Hicks <khicks@nvidia.com>
249ca20 to
855e0e3
Compare
Summary
When a gateway replica accepts a credential for the first time, it now emits an Informational OCSF Authentication event with status Success. The caller's request proceeds exactly as before. The event records:
OpenID,mtls,sandbox_jwt,compute_driver, ork8s_service_account).Every gRPC request authenticates, and an idle sandbox's supervisor polls the gateway several times a minute, so an event per request would bury user logons. Each credential therefore logs on once: later requests with the same bearer token or client certificate emit nothing until the credential has been in use for an hour, when it logs on again.
Requests admitted by
allow_unauthenticated_users, or by a gateway with no authentication configured, emit no success event, since no credential was verified.Related Issue
Refs #2912
This is the fifth of several PRs for #2912 and does not close it. Success events are on by default with no setting to turn them off, so the criterion "Authentication success events can be enabled or disabled independently through documented operator configuration" stays open on purpose: we'd like to see real volumes before adding the knob.
Changes
auth::audit::Logons. A record of credentials that have recently logged on, held onServerStateand shared by every connection to the replica. It keys on a SHA-256 digest (throughopenshell-crypto) of the principal and the credential that authenticated it: the parsed bearer token, or the fingerprint of the verified client certificate for operators and mTLS users. Headers the authenticator ignored, such as anAuthorization: Basicheader on an mTLS connection or a differently casedBearerscheme, therefore cannot force new logons, and a renewed certificate with the same subject logs on again. Digests stay in memory, and a digest failure logs the credential on rather than deduplicating it. It holds up to 16,384 credentials. Only a new credential evicts the oldest early, so a full record of credentials still in use records nothing more.AuthGrpcRoutercallsaudit::emit_logononce it has established the principal, before authorization runs, so a caller that authenticates and is then refused records both the logon and the denial. Health and reflection requests skip it, as they skip authentication.ocsf-json-export.mdxdescribes the event, when a credential logs on again, and that consumers selecting rejected requests should filter onstatus_id: 2rather thanclass_uidalone.logging.mdxupdates theAUTH:row and adds a shorthand example.Events never include presented credentials or request headers other than the canonical request ID.
Testing
cargo nextest run -p openshell-server -p openshell-ocsf: all 2,604 tests pass.cargo clippy --workspace --all-targets -- -D warningsAuthorizationheader on an mTLS connection, or the case of theBearerscheme, does not make a new logon.k8s_service_accountandcompute_driver.Follow-ups
IssueSandboxToken, with the checks insideIssueSandboxToken,RefreshSandboxToken, andGetCurrentUser.Checklist