HDDS-6525. Add audit log for S3Gateway#3252
Conversation
|
@adoroszlai @ferhui Could you help to review this PR? |
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @symious for working on this.
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/S3Utils.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/RootEndpoint.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/RootEndpoint.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/EndpointBase.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/S3Utils.java
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/ClientIpFilter.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/util/S3Utils.java
Outdated
Show resolved
Hide resolved
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/S3GAction.java
Outdated
Show resolved
Hide resolved
|
@adoroszlai Thank you for the detailed review. Fixed with the comments except the default value one. |
|
Thanks @symious for updating the patch. There is a compile error after conflict resolution: |
|
Updated, please have a look. |
|
Thanks @symious for updating the patch. LGTM. Can you please resolve the conflict? |
|
@adoroszlai Conflict solved, please have a look. |
|
@adoroszlai @ferhui Thanks for the review. |
|
|
||
| if (clientIp == null || clientIp.isEmpty()) { | ||
| // extract from forward ips | ||
| String ipForwarded = httpServletRequest.getHeader("x-forwarded-for"); |
There was a problem hiding this comment.
What is the rational for picking x-real-ip first before x-forwarded-for
For the purpose of auditing it might make sense to include both.
There was a problem hiding this comment.
Tried to find some comparisions, but can not find any definite answers:
It seems that even though the leftmost value of X-Forwarded-For is generally the original client IP address, this is not universally so, and there exist modules for at least Apache and Nginx web servers to provide the correct resolution of the client IP address and setting it as the X-Real-IP value.
It denpends on how much you know the network between the client and the server, and how much you trust these headers.
However, since any proxy can modify/add these headers freely, there is no guarantee the IP is of a real client.
| @Provider | ||
| @PreMatching | ||
| @Priority(ClientIpFilter.PRIORITY) | ||
| public class ClientIpFilter implements ContainerRequestFilter { |
There was a problem hiding this comment.
I think for purposes of audit trail it makes sense to capture as many details as possible.
There was a problem hiding this comment.
Is this for adding both header's IP in audit log?
Currently the audit log has one field to record IP, if added multi IPs in one field, might incur some errors when users are operating on this field.
|
|
||
|
|
||
| S3GAction s3GAction = S3GAction.GET_BUCKET; | ||
| Map<String, String> auditParams = S3Utils.genAuditParam( |
There was a problem hiding this comment.
For audit purposes, it makes sense to capture the entire query sent and doing it centrally once similar to how the client IP is calculated. It will help identify bad clients who are not setting the correct params.
There was a problem hiding this comment.
Sure, I updated the generation of the audit params in a new ticket: #3325.
Could you help to check?
What changes were proposed in this pull request?
Currently There is no audit log for S3gateway.
This ticket is to add audit log for S3gateway
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-6525
How was this patch tested?
unit test.