pkg/server: log api key in debug traffic
Change-Id: I677832200c9599c37c22cf742b396ca12542a803
This commit is contained in:
parent
4e5e6c8e5c
commit
2c47a9b1d9
@ -16,6 +16,7 @@ import (
|
||||
|
||||
"storj.io/common/identity"
|
||||
"storj.io/common/rpc/rpcpeer"
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
@ -61,6 +62,7 @@ type nodeRequestLog struct {
|
||||
GRPCMethod string `json:"grpc_method"`
|
||||
PeerAddress string `json:"peer_address"`
|
||||
PeerNodeID string `json:"peer_node_id"`
|
||||
APIKey string `json:"api_key,omitempty"`
|
||||
Msg interface{} `json:"msg"`
|
||||
}
|
||||
|
||||
@ -69,6 +71,7 @@ func prepareRequestLog(ctx context.Context, req, server interface{}, methodName
|
||||
GRPCService: fmt.Sprintf("%T", server),
|
||||
GRPCMethod: methodName,
|
||||
PeerAddress: "<no peer???>",
|
||||
APIKey: "",
|
||||
Msg: req,
|
||||
}
|
||||
if peer, err := rpcpeer.FromContext(ctx); err == nil {
|
||||
@ -79,6 +82,9 @@ func prepareRequestLog(ctx context.Context, req, server interface{}, methodName
|
||||
reqLog.PeerNodeID = fmt.Sprintf("<no peer id: %v>", err)
|
||||
}
|
||||
}
|
||||
if key, ok := auth.GetAPIKey(ctx); ok {
|
||||
reqLog.APIKey = string(key)
|
||||
}
|
||||
return json.Marshal(reqLog)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user