Skip to content
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

Log request body to audit logs #5071

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

olkkoti
Copy link

@olkkoti olkkoti commented Jan 30, 2025

Description

Currently we do not get request body to audit log, as requests are already authenticated in header verifier level, which does not have access to request body.

SecurityRestFilter has the whole RestRequest object, but it does not authenticate it again. Also, it does not authorize the request if the route is not a named one. The idea here is to do logGrantedPrivileges call even if we do not authorize. This way we will get the request body to audit log.

Issues Resolved

[BUG] audit_request_body missing for REST since 2.11

Testing

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • API changes companion pull request created
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@olkkoti olkkoti changed the title Log granted privileges on SecurityRestFilter even if we do not author… Log request body to audit logs Jan 30, 2025
Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about adding auditLog.logSucceededLogin(user.getName(), request); before each call to delegate.handleRequest(request, channel, client);?

We could also remove these calls from the BackendRegistry and rely on them to be called within here.

To enable audit logs for this category, you would need to add then AUTHENTICATED category as one of the enabled categories.

@olkkoti
Copy link
Author

olkkoti commented Feb 1, 2025

How about like this?

@olkkoti olkkoti force-pushed the auditlog-without-rest-authorization branch 4 times, most recently from aef31e2 to c49ca35 Compare February 3, 2025 16:11
@olkkoti
Copy link
Author

olkkoti commented Feb 3, 2025

Hmm. Apparently at least in test cases user is allowed to be null here. I guess then we just dont do audit log? Or would it be better to call it with null effectiveUser?

@olkkoti olkkoti force-pushed the auditlog-without-rest-authorization branch 2 times, most recently from bc1e52d to e837d29 Compare February 3, 2025 17:08
…try in order to get request body.

This fixes the issue opensearch-project#4094

Signed-off-by: Timo Olkkonen <[email protected]>
@olkkoti olkkoti force-pushed the auditlog-without-rest-authorization branch from e837d29 to e4f6268 Compare February 8, 2025 08:11
@olkkoti olkkoti requested a review from cwperks February 8, 2025 08:11
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.

2 participants