MCPcopy Create free account
hub / github.com/actiontech/dtle / JWTTokenAdapter

Function JWTTokenAdapter

api/route.go:207–218  ·  view source on GitHub ↗

JWTTokenAdapter is a `echo` middleware, by rewriting the header, the jwt token support header "Authorization: {token}" and "Authorization: Bearer {token}".

()

Source from the content-addressed store, hash-verified

205// JWTTokenAdapter is a `echo` middleware, by rewriting the header, the jwt token support header
206// "Authorization: {token}" and "Authorization: Bearer {token}".
207func JWTTokenAdapter() echo.MiddlewareFunc {
208 return func(next echo.HandlerFunc) echo.HandlerFunc {
209 return func(c echo.Context) error {
210 auth := c.Request().Header.Get(echo.HeaderAuthorization)
211 if auth != "" && !strings.HasPrefix(auth, middleware.DefaultJWTConfig.AuthScheme) {
212 c.Request().Header.Set(echo.HeaderAuthorization,
213 fmt.Sprintf("%s %s", middleware.DefaultJWTConfig.AuthScheme, auth))
214 }
215 return next(c)
216 }
217 }
218}
219
220func AuthFilter() echo.MiddlewareFunc {
221 return func(next echo.HandlerFunc) echo.HandlerFunc {

Callers 1

SetupApiServerFunction · 0.85

Calls 2

GetMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected