mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 13:40:22 +03:00
add audit/admin trace support for browser requests (#10947)
To support this functionality we had to fork the gorilla/rpc package with relevant changes
This commit is contained in:
+18
-3
@@ -23,9 +23,10 @@ import (
|
||||
assetfs "github.com/elazarl/go-bindata-assetfs"
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
jsonrpc "github.com/gorilla/rpc/v2"
|
||||
"github.com/gorilla/rpc/v2/json2"
|
||||
"github.com/minio/minio/browser"
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
jsonrpc "github.com/minio/minio/pkg/rpc"
|
||||
"github.com/minio/minio/pkg/rpc/json2"
|
||||
)
|
||||
|
||||
// webAPI container for Web API.
|
||||
@@ -76,9 +77,23 @@ func registerWebRouter(router *mux.Router) error {
|
||||
webRPC := jsonrpc.NewServer()
|
||||
webRPC.RegisterCodec(codec, "application/json")
|
||||
webRPC.RegisterCodec(codec, "application/json; charset=UTF-8")
|
||||
webRPC.RegisterAfterFunc(func(ri *jsonrpc.RequestInfo) {
|
||||
if ri != nil {
|
||||
claims, _, _ := webRequestAuthenticate(ri.Request)
|
||||
bucketName, objectName := extractBucketObject(ri.Args)
|
||||
ri.Request = mux.SetURLVars(ri.Request, map[string]string{
|
||||
"bucket": bucketName,
|
||||
"object": objectName,
|
||||
})
|
||||
if globalHTTPTrace.HasSubscribers() {
|
||||
globalHTTPTrace.Publish(WebTrace(ri))
|
||||
}
|
||||
logger.AuditLog(ri.ResponseWriter, ri.Request, ri.Method, claims.Map())
|
||||
}
|
||||
})
|
||||
|
||||
// Register RPC handlers with server
|
||||
if err := webRPC.RegisterService(web, "Web"); err != nil {
|
||||
if err := webRPC.RegisterService(web, "web"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user