MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / grpcStreamAuthInterceptor

Method grpcStreamAuthInterceptor

internal/api/grpc.go:67–88  ·  view source on GitHub ↗
(
	srv interface{},
	ss grpc.ServerStream,
	info *grpc.StreamServerInfo,
	handler grpc.StreamHandler,
)

Source from the content-addressed store, hash-verified

65}
66
67func (s *GrpcServer) grpcStreamAuthInterceptor(
68 srv interface{},
69 ss grpc.ServerStream,
70 info *grpc.StreamServerInfo,
71 handler grpc.StreamHandler,
72) error {
73 if strings.HasPrefix(info.FullMethod, "/auth.v1.AuthService/LoginBy") ||
74 strings.HasPrefix(info.FullMethod, "/auth.v1.AuthService/RefreshToken") {
75 return handler(srv, ss)
76 }
77
78 actor, err := s.authUserActor(ss.Context())
79 if err != nil {
80 return err
81 }
82 ctx := contextutil.SetActor(ss.Context(), actor)
83
84 wrapped := WrapServerStream(ss)
85 wrapped.WrappedContext = ctx
86
87 return handler(srv, wrapped)
88}
89
90func (s *GrpcServer) authUserActor(ctx context.Context) (*accesscontrol.Actor, error) {
91 md, ok := metadata.FromIncomingContext(ctx)

Callers

nothing calls this directly

Calls 4

authUserActorMethod · 0.95
SetActorFunction · 0.92
WrapServerStreamFunction · 0.85
ContextMethod · 0.80

Tested by

no test coverage detected