Skip to content

Commit bf890bc

Browse files
Do not overwrite the exsting Twirp headers on the context in the auth middleware
1 parent 22bedbb commit bf890bc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

auth.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/twitchtv/twirp"
2121

2222
"github.com/livekit/protocol/auth"
23+
2324
"github.com/livekit/server-sdk-go/v2/signalling"
2425
)
2526

@@ -61,5 +62,15 @@ func (b authBase) withAuth(ctx context.Context, opt authOption, options ...authO
6162
return nil, err
6263
}
6364

64-
return twirp.WithHTTPRequestHeaders(ctx, signalling.NewHTTPHeaderWithToken(token))
65+
h := signalling.NewHTTPHeaderWithToken(token)
66+
ctxH, _ := twirp.HTTPRequestHeaders(ctx)
67+
68+
// merge new header with the ones already present in the context
69+
for k, vv := range ctxH {
70+
for _, v := range vv {
71+
h.Add(k, v)
72+
}
73+
}
74+
75+
return twirp.WithHTTPRequestHeaders(ctx, h)
6576
}

0 commit comments

Comments
 (0)