@@ -6,27 +6,28 @@ import (
66
77 "github.com/go-http-utils/headers"
88 "github.com/go-jose/go-jose/v4"
9- "github.com/platform-mesh/golang-commons/context"
9+
10+ pmcontext "github.com/platform-mesh/golang-commons/context"
1011)
1112
1213const tokenAuthPrefix = "BEARER"
1314
1415var SignatureAlgorithms = []jose.SignatureAlgorithm {jose .RS256 }
1516
1617// StoreWebToken returns middleware that extracts a JWT from the HTTP `Authorization` header
17- // and stores it in the request context for downstream handlers.
18+ // and stores it in the request pmcontext for downstream handlers.
1819//
1920// The middleware looks for an Authorization header of the form `Bearer <token>` (scheme match is
20- // case-insensitive). When present, the token is added to the context via
21+ // case-insensitive). When present, the token is added to the pmcontext via
2122// context.AddWebTokenToContext using the package's SignatureAlgorithms. If the header is absent,
22- // malformed, or not a Bearer token, the request context is left unchanged.
23+ // malformed, or not a Bearer token, the request pmcontext is left unchanged.
2324func StoreWebToken () func (http.Handler ) http.Handler {
2425 return func (next http.Handler ) http.Handler {
2526 return http .HandlerFunc (func (responseWriter http.ResponseWriter , request * http.Request ) {
2627 ctx := request .Context ()
2728 auth := strings .Split (request .Header .Get (headers .Authorization ), " " )
2829 if len (auth ) > 1 && strings .ToUpper (auth [0 ]) == tokenAuthPrefix {
29- ctx = context .AddWebTokenToContext (ctx , auth [1 ], SignatureAlgorithms )
30+ ctx = pmcontext .AddWebTokenToContext (ctx , auth [1 ], SignatureAlgorithms )
3031 }
3132
3233 next .ServeHTTP (responseWriter , request .WithContext (ctx ))
0 commit comments