Skip to content

feat(auth-server): audit logging - #22086

Open
sfoster1 wants to merge 6 commits into
edgefrom
exec-2874-auth-server-audit-logging
Open

feat(auth-server): audit logging#22086
sfoster1 wants to merge 6 commits into
edgefrom
exec-2874-auth-server-audit-logging

Conversation

@sfoster1

Copy link
Copy Markdown
Member

Overview

Add audit logging to the auth server.

We log the settings endpoints straightforwardly with little customization. User creation and editing needs custom request body handling to make sure we don't log passwords.

Oauth stuff takes a little more annoying insight. We could log in the endpoints, but then we'd have to look at the token responses that come from oauthlib, and by the time they get back to the endpoint the token responses are already serialized to form-data responses and we'd have to reparse them, which would be annoying. Instead, we can integrate logging into the oauth backend with a little callback that creates tasks to send the audit log messages.

The audit log messages are also a little annoying; they have to be done in a way that eventually bypasses user-notes requirements, since a user can set user-note minimum length requirements and we don't want to have to emit 50,000 letters "a" or whatever. For now, I'm just not sending them, since those requirements aren't correctly enforced. When we do enforce it, we'll either have to add a special thing to the messages you send on the unix domain socket to be logged that indicates these are system messages, or reserve the username system for things like this.

Test Plan and Hands on Testing

  • push to a flex and note that stuff gets logged when you do things on the auth server

Changelog

  • integrate audit logging into auth server endpoints

Review requests

  • happy with the task thing?

Risk assessment

low; the code here is in execution pretty simple.

Base automatically changed from fix-audit-middleware to edge July 28, 2026 21:07
sfoster1 added 6 commits July 28, 2026 17:09
We can't do this with the normal fastapi dependencies because the work
of the endpoint functions, including request and response handling, is
delegated to oauthlib and I've never wanted anything more than to not
inspect the raw results. Instead, we can poke a callback into the
request validator and with a little source reading in oauthlib,
- Anywhere we return False, that's a failed login, so log that
- The last login check is the scope validity check, so if that returns
true then we're going to log in, so log that

Also, we might as well do this to log logins to the auth server logs,
since that seems like a pretty helpful thing to have.

We're logging "login expired" if a refresh token isn't found, but I
don't want to log every refresh token login because it would be a
million of them and it means somebody already provided the right
credentials.
nothing uses this, my oath upon it
@sfoster1
sfoster1 force-pushed the exec-2874-auth-server-audit-logging branch from 54b17e4 to 66cf0a2 Compare July 28, 2026 21:09
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