HDFS-7232. Populate hostname in httpfs audit log (Zoran Dimitrijevic via aw)
This commit is contained in:
parent
7ab754545d
commit
828429dec1
@ -59,6 +59,7 @@
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
@ -164,9 +165,10 @@ private void enforceRootPath(HttpFSFileSystem.Operation op, String path) {
|
|||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Response getRoot(@QueryParam(OperationParam.NAME) OperationParam op,
|
public Response getRoot(@QueryParam(OperationParam.NAME) OperationParam op,
|
||||||
@Context Parameters params)
|
@Context Parameters params,
|
||||||
|
@Context HttpServletRequest request)
|
||||||
throws IOException, FileSystemAccessException {
|
throws IOException, FileSystemAccessException {
|
||||||
return get("", op, params);
|
return get("", op, params, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeAbsolute(String path) {
|
private String makeAbsolute(String path) {
|
||||||
@ -193,12 +195,14 @@ private String makeAbsolute(String path) {
|
|||||||
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
|
||||||
public Response get(@PathParam("path") String path,
|
public Response get(@PathParam("path") String path,
|
||||||
@QueryParam(OperationParam.NAME) OperationParam op,
|
@QueryParam(OperationParam.NAME) OperationParam op,
|
||||||
@Context Parameters params)
|
@Context Parameters params,
|
||||||
|
@Context HttpServletRequest request)
|
||||||
throws IOException, FileSystemAccessException {
|
throws IOException, FileSystemAccessException {
|
||||||
UserGroupInformation user = HttpUserGroupInformation.get();
|
UserGroupInformation user = HttpUserGroupInformation.get();
|
||||||
Response response;
|
Response response;
|
||||||
path = makeAbsolute(path);
|
path = makeAbsolute(path);
|
||||||
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
||||||
|
MDC.put("hostname", request.getRemoteAddr());
|
||||||
switch (op.value()) {
|
switch (op.value()) {
|
||||||
case OPEN: {
|
case OPEN: {
|
||||||
//Invoking the command directly using an unmanaged FileSystem that is
|
//Invoking the command directly using an unmanaged FileSystem that is
|
||||||
@ -334,12 +338,14 @@ public Response get(@PathParam("path") String path,
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Response delete(@PathParam("path") String path,
|
public Response delete(@PathParam("path") String path,
|
||||||
@QueryParam(OperationParam.NAME) OperationParam op,
|
@QueryParam(OperationParam.NAME) OperationParam op,
|
||||||
@Context Parameters params)
|
@Context Parameters params,
|
||||||
|
@Context HttpServletRequest request)
|
||||||
throws IOException, FileSystemAccessException {
|
throws IOException, FileSystemAccessException {
|
||||||
UserGroupInformation user = HttpUserGroupInformation.get();
|
UserGroupInformation user = HttpUserGroupInformation.get();
|
||||||
Response response;
|
Response response;
|
||||||
path = makeAbsolute(path);
|
path = makeAbsolute(path);
|
||||||
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
||||||
|
MDC.put("hostname", request.getRemoteAddr());
|
||||||
switch (op.value()) {
|
switch (op.value()) {
|
||||||
case DELETE: {
|
case DELETE: {
|
||||||
Boolean recursive =
|
Boolean recursive =
|
||||||
@ -385,12 +391,14 @@ public Response post(InputStream is,
|
|||||||
@Context UriInfo uriInfo,
|
@Context UriInfo uriInfo,
|
||||||
@PathParam("path") String path,
|
@PathParam("path") String path,
|
||||||
@QueryParam(OperationParam.NAME) OperationParam op,
|
@QueryParam(OperationParam.NAME) OperationParam op,
|
||||||
@Context Parameters params)
|
@Context Parameters params,
|
||||||
|
@Context HttpServletRequest request)
|
||||||
throws IOException, FileSystemAccessException {
|
throws IOException, FileSystemAccessException {
|
||||||
UserGroupInformation user = HttpUserGroupInformation.get();
|
UserGroupInformation user = HttpUserGroupInformation.get();
|
||||||
Response response;
|
Response response;
|
||||||
path = makeAbsolute(path);
|
path = makeAbsolute(path);
|
||||||
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
||||||
|
MDC.put("hostname", request.getRemoteAddr());
|
||||||
switch (op.value()) {
|
switch (op.value()) {
|
||||||
case APPEND: {
|
case APPEND: {
|
||||||
Boolean hasData = params.get(DataParam.NAME, DataParam.class);
|
Boolean hasData = params.get(DataParam.NAME, DataParam.class);
|
||||||
@ -469,12 +477,14 @@ public Response put(InputStream is,
|
|||||||
@Context UriInfo uriInfo,
|
@Context UriInfo uriInfo,
|
||||||
@PathParam("path") String path,
|
@PathParam("path") String path,
|
||||||
@QueryParam(OperationParam.NAME) OperationParam op,
|
@QueryParam(OperationParam.NAME) OperationParam op,
|
||||||
@Context Parameters params)
|
@Context Parameters params,
|
||||||
|
@Context HttpServletRequest request)
|
||||||
throws IOException, FileSystemAccessException {
|
throws IOException, FileSystemAccessException {
|
||||||
UserGroupInformation user = HttpUserGroupInformation.get();
|
UserGroupInformation user = HttpUserGroupInformation.get();
|
||||||
Response response;
|
Response response;
|
||||||
path = makeAbsolute(path);
|
path = makeAbsolute(path);
|
||||||
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
|
||||||
|
MDC.put("hostname", request.getRemoteAddr());
|
||||||
switch (op.value()) {
|
switch (op.value()) {
|
||||||
case CREATE: {
|
case CREATE: {
|
||||||
Boolean hasData = params.get(DataParam.NAME, DataParam.class);
|
Boolean hasData = params.get(DataParam.NAME, DataParam.class);
|
||||||
|
@ -325,6 +325,9 @@ Release 2.7.0 - UNRELEASED
|
|||||||
|
|
||||||
HDFS-7277. Remove explicit dependency on netty 3.2 in BKJournal. (wheat9)
|
HDFS-7277. Remove explicit dependency on netty 3.2 in BKJournal. (wheat9)
|
||||||
|
|
||||||
|
HDFS-7232. Populate hostname in httpfs audit log (Zoran Dimitrijevic
|
||||||
|
via aw)
|
||||||
|
|
||||||
Release 2.6.0 - UNRELEASED
|
Release 2.6.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
Loading…
Reference in New Issue
Block a user