-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add filter for logging principal of incoming requests #3649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.7.x
Are you sure you want to change the base?
Conversation
🎉 All Contributor License Agreements have been signed. Ready to merge. |
This comment has been minimized.
This comment has been minimized.
457a732
to
13c77dc
Compare
13c77dc
to
b4d68a5
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put an example log message for this PR? I'd like to see what the message looks like to review for feedback as well if possible. Also that's a lot of SonarCube alerts in this repo, hoping you have a techdebt item to resolve or ignore that particular empty body rule for the repo?
@@ -59,6 +62,10 @@ public SchemaRegistryRestApplication(Properties props) throws RestConfigExceptio | |||
@Override | |||
protected void configurePreResourceHandling(ServletContextHandler context) { | |||
super.configurePreResourceHandling(context); | |||
PrincipalLoggingFilter principalLoggingFilter = new PrincipalLoggingFilter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this pull out the user_id field from the REQUEST types? I am not super familiar with this code base to know what this does implicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all requests that come into SR will pass through this request filter, which will set the principal user (unique identifier for the request sender) in a principalContext. this is needed because the logs are populated at the service level, not at the request level - so we keep it in a principalContext which can be read when the actual CRUD SR calls happen. I have also added a sample log to the PR description - let me know if you want it reformatted another way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, yeah I wasn't sure which id or reference the principalContext would use by default. This and the example log message clarify that, thanks!
What
Add filter to locally log principal of user sending incoming request.
Example log:
[2025-04-01 15:37:05,444] INFO [6c95ca51-f2ec-497b-ac48-d27eea303cdf] Resource association log - (Principal, schemaHash): (u-dummy, a236344d3b2bbe2cc09439868bfc7168) (io.confluent.kafka.schemaregistry.storage.KafkaSchemaRegistry:2646)
Checklist
References
JIRA:
Test & Review
Open questions / Follow-ups