Skip to content

Ai gateway observability/log token admin page - #74619

Open
alex-m-brown wants to merge 14 commits into
ai-gateway-observability/user-log-token-libfrom
ai-gateway-observability/log-token-admin-page
Open

Ai gateway observability/log token admin page#74619
alex-m-brown wants to merge 14 commits into
ai-gateway-observability/user-log-token-libfrom
ai-gateway-observability/log-token-admin-page

Conversation

@alex-m-brown

@alex-m-brown alex-m-brown commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This change adds the administrator page /admin/log_token. The page changes a user id to its log tokens and vice versa. It uses the module Cdo::UserLogToken from #74609.

Sentry and the AI gateway will hold a log token in the place of a user id. An engineer who has a token from a log cannot find the account. An engineer who has an account cannot find its records.

Direction 1: from a user id to its tokens

Retrieving the tokens from a user id reveals the log tokens for each destination. This token can then be used to search each destination for the user's logs.

Direction 2: from a token to its user id

This direction identifies a student. It has these controls:

  • The form sends a POST request, not a GET request. The token does not go into the URL. As a result, the token does not go into the request log. This feature must keep identifiers out of that log.
  • You must give a reason. You can write any text, and no program examines it. But you cannot leave the reason empty.
  • The module writes the audit record. The controller does not write it. Cdo::UserLogToken.resolve stops with an error if you do not give an actor and a reason. As a result, a person at a production console cannot prevent the audit record. The module also writes a record when it cannot read the token.

Links

Testing story

The file dashboard/test/controllers/admin_users_controller_test.rb has unit tests covering both directions and their permissions.

Screenshot 2026-08-14 at 11 57 45 AM Screenshot 2026-08-14 at 12 00 00 PM Screenshot 2026-08-14 at 12 32 25 PM Screenshot 2026-08-14 at 12 33 02 PM Screenshot 2026-08-14 at 12 33 40 PM

Privacy and security

This page identifies a student from a token, and the user must be an admin to open the page.

The audit record does not hold the token. It holds the administrator, the user, the destination, and the reason.

alex-m-brown and others added 7 commits August 13, 2026 10:40
Introduce lib/cdo/user_log_token.rb, which mints and resolves "log tokens":
reversible pseudonyms of user ids, so raw user ids stay out of our logs and
out of third-party systems.

Keys come from the new user_log_token_keys config, a JSON object of
version => 32+ random bytes (base64). The highest version encrypts; every
version is retained so previously written tokens stay readable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adds /admin_users/log_token, an admin-only form that resolves a log token
to the user id it stands for, so an engineer holding a token from a log or
a third-party system can get back to the account.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…into ai-gateway-observability/user-log-token-lib
@alex-m-brown
alex-m-brown changed the base branch from staging to ai-gateway-observability/user-log-token-lib August 13, 2026 19:24
@alex-m-brown
alex-m-brown changed the base branch from ai-gateway-observability/user-log-token-lib to staging August 14, 2026 14:09
@alex-m-brown
alex-m-brown changed the base branch from staging to ai-gateway-observability/user-log-token-lib August 14, 2026 14:10
alex-m-brown and others added 3 commits August 14, 2026 10:13
Adds /admin_users/log_token, an admin-only form that resolves a log token
to the user id it stands for, so an engineer holding a token from a log or
a third-party system can get back to the account.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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