MCPcopy Index your code
hub / github.com/chainloop-dev/chainloop / AuthFromQueryParam

Function AuthFromQueryParam

pkg/middlewares/http/jwt.go:39–49  ·  view source on GitHub ↗

AuthFromQueryParam is a middleware that extracts the token from the query parameter and verifies it

(keyFunc jwt.Keyfunc, claimsFunc ClaimsFunc, signingMethod jwt.SigningMethod, next nhttp.Handler)

Source from the content-addressed store, hash-verified

37
38// AuthFromQueryParam is a middleware that extracts the token from the query parameter and verifies it
39func AuthFromQueryParam(keyFunc jwt.Keyfunc, claimsFunc ClaimsFunc, signingMethod jwt.SigningMethod, next nhttp.Handler) nhttp.Handler {
40 return nhttp.HandlerFunc(func(w http.ResponseWriter, r *nhttp.Request) {
41 token := r.URL.Query().Get("t")
42 if token == "" {
43 nhttp.Error(w, "missing token", nhttp.StatusUnauthorized)
44 return
45 }
46
47 verifyJWTAndServeNext(w, r, token, keyFunc, claimsFunc, signingMethod, next)
48 })
49}
50
51// verifyJWTAndServeNext verifies the token and serves the next handler
52func verifyJWTAndServeNext(w http.ResponseWriter, r *nhttp.Request, token string, keyFunc jwt.Keyfunc, claimsFunc ClaimsFunc, signingMethod jwt.SigningMethod, next nhttp.Handler) {

Callers 1

TestAuthFromQueryParamFunction · 0.85

Calls 4

verifyJWTAndServeNextFunction · 0.85
GetMethod · 0.65
ErrorMethod · 0.65
QueryMethod · 0.45

Tested by 1

TestAuthFromQueryParamFunction · 0.68