mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/grafana/dskit/middleware"
|
|
"github.com/grafana/dskit/user"
|
|
"github.com/grafana/tempo/pkg/util"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
var fakeHTTPAuthMiddleware = middleware.Func(func(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ctx := user.InjectOrgID(r.Context(), util.FakeTenantID)
|
|
next.ServeHTTP(w, r.WithContext(ctx))
|
|
})
|
|
})
|
|
|
|
var fakeGRPCAuthUniaryMiddleware = func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
ctx = user.InjectOrgID(ctx, util.FakeTenantID)
|
|
return handler(ctx, req)
|
|
}
|
|
|
|
var fakeGRPCAuthStreamMiddleware = func(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
|
ctx := user.InjectOrgID(ss.Context(), util.FakeTenantID)
|
|
return handler(srv, serverStream{
|
|
ctx: ctx,
|
|
ServerStream: ss,
|
|
})
|
|
}
|
|
|
|
type serverStream struct {
|
|
ctx context.Context
|
|
grpc.ServerStream
|
|
}
|
|
|
|
func (ss serverStream) Context() context.Context {
|
|
return ss.ctx
|
|
}
|