-
-
Notifications
You must be signed in to change notification settings - Fork 954
Open
Description
for the generated ServerInterfaceWrapper below, the middleware is executed before the below function is executed. Which is correct. I want to check the set APIKeyAuthScopes, but since the context is set after the middleware is called, I cannot do so.
func (w *ServerInterfaceWrapper) ValidateAPIKey(ctx echo.Context) error {
var err error
ctx.Set(APIKeyAuthScopes, []string{"auth"})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.ValidateAPIKey(ctx)
return err
}
Here is my middleware
func Middleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
printContext(ctx, true)
printHeaders(ctx)
keyScopes, requiresKey := ctx.Get(APIKeyAuthScopes).([]string)
bearerScopes, requiresBearer := ctx.Get(BearerAuthScopes).([]string)
// do something and return appropriate
}
}
This is my echo server
// web server based on echo
e := echo.New()
e.Use(middleware.CORS())
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(auth.Middleware)
e.Validator = &shared.EchoValidator{Validator: shared.Validator}
auth.RegisterHandlers(e, &auth.ServerHandler{})
Is there a step I am missing?
Metadata
Metadata
Assignees
Labels
No labels