feature: Add client ip to inbound request information (#1678)
* feature: Add client ip to inbound request information * feature (workers): Add the user's client IP to a session's connection information (#1749)
This commit is contained in:
36 files changed
+563
-169
No files matched your search
@@ -67,7 +67,7 @@ func (c *Controller) handler(props HandlerProperties) (http.Handler, error) {
|
||||
commonWrappedHandler := wrapHandlerWithCommonFuncs(corsWrappedHandler, c, props)
|
||||
callbackInterceptingHandler := wrapHandlerWithCallbackInterceptor(commonWrappedHandler, c)
|
||||
printablePathCheckHandler := cleanhttp.PrintablePathCheckHandler(callbackInterceptingHandler, nil)
|
||||
eventsHandler, err := common.WrapWithEventsHandler(printablePathCheckHandler, c.conf.Eventer, c.kms)
|
||||
eventsHandler, err := common.WrapWithEventsHandler(printablePathCheckHandler, c.conf.Eventer, c.kms, props.ListenerConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -292,6 +292,7 @@ func wrapHandlerWithCommonFuncs(h http.Handler, c *Controller, props HandlerProp
|
||||
// piggyback some eventing fields with the auth info proto message
|
||||
requestInfo.EventId = info.EventId
|
||||
requestInfo.TraceId = info.Id
|
||||
requestInfo.ClientIp = info.ClientIp
|
||||
} else {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
event.WriteError(ctx, op, errors.New("unable to read event request info from context"))
|
||||
|
||||
@@ -281,7 +281,7 @@ func TestList(t *testing.T) {
|
||||
Endpoint: "tcp://127.0.0.1:22",
|
||||
})
|
||||
|
||||
c := session.TestConnection(t, conn, sess.PublicId, "127.0.0.1", 22, "127.0.0.2", 23)
|
||||
c := session.TestConnection(t, conn, sess.PublicId, "127.0.0.1", 22, "127.0.0.2", 23, "127.0.0.1")
|
||||
|
||||
status, states := convertStates(sess.States)
|
||||
|
||||
@@ -326,7 +326,7 @@ func TestList(t *testing.T) {
|
||||
Endpoint: "tcp://127.0.0.1:22",
|
||||
})
|
||||
|
||||
c = session.TestConnection(t, conn, sess.PublicId, "127.0.0.1", 22, "127.0.0.2", 23)
|
||||
c = session.TestConnection(t, conn, sess.PublicId, "127.0.0.1", 22, "127.0.0.2", 23, "127.0.0.1")
|
||||
|
||||
status, states = convertStates(sess.States)
|
||||
|
||||
|
||||
@@ -409,6 +409,7 @@ func (ws *workerServiceServer) ConnectConnection(ctx context.Context, req *pbs.C
|
||||
ClientTcpPort: req.GetClientTcpPort(),
|
||||
EndpointTcpAddress: req.GetEndpointTcpAddress(),
|
||||
EndpointTcpPort: req.GetEndpointTcpPort(),
|
||||
UserClientIp: req.GetUserClientIp(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -125,6 +125,7 @@ func requestCtxInterceptor(
|
||||
PublicId: requestInfo.PublicId,
|
||||
Method: requestInfo.Method,
|
||||
Path: requestInfo.Path,
|
||||
ClientIp: requestInfo.ClientIp,
|
||||
}
|
||||
interceptorCtx, err = event.NewRequestInfoContext(interceptorCtx, info)
|
||||
if err != nil {
|
||||
|
||||
@@ -40,22 +40,6 @@ func (c *Controller) startListeners(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO: As I write this Vault's having this code audited, make sure to
|
||||
// port over any recommendations
|
||||
//
|
||||
// We perform validation on the config earlier, we can just cast here
|
||||
if _, ok := ln.config["x_forwarded_for_authorized_addrs"]; ok {
|
||||
hopSkips := ln.config["x_forwarded_for_hop_skips"].(int)
|
||||
authzdAddrs := ln.config["x_forwarded_for_authorized_addrs"].([]*sockaddr.SockAddrMarshaler)
|
||||
rejectNotPresent := ln.config["x_forwarded_for_reject_not_present"].(bool)
|
||||
rejectNonAuthz := ln.config["x_forwarded_for_reject_not_authorized"].(bool)
|
||||
if len(authzdAddrs) > 0 {
|
||||
handler = vaulthttp.WrapForwardedForHandler(handler, authzdAddrs, rejectNotPresent, rejectNonAuthz, hopSkips)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Resolve it here to avoid race conditions if the base context is
|
||||
// replaced
|
||||
cancelCtx := c.baseContext
|
||||
|
||||
@@ -76,6 +76,7 @@ func TestSessionCleanupJob(t *testing.T) {
|
||||
ClientTcpPort: 22,
|
||||
EndpointTcpAddress: "127.0.0.1",
|
||||
EndpointTcpPort: 22,
|
||||
UserClientIp: "127.0.0.1",
|
||||
})
|
||||
require.NoError(err)
|
||||
require.Len(cs, 2)
|
||||
|
||||
Reference in new issue
Block a user