Skip to content

Both v3/v4 returns "Internal Server Error 500" on KeyAuth function false #1323

Closed
@ilzheev

Description

@ilzheev
e := echo.New()
authGroup := e.Group("/v1")
authGroup.Use(middleware.KeyAuth(func(key string, c echo.Context) (bool, error) {
		user := api.service.CheckUser(key) // checks if user with "key" exists into db
		if user != nil {
			api.user = user
			return true, nil
		}
		err := fmt.Errorf("Invalid auth key: %s", key)
		log.Error(err)
		return false, err
}))

Expected behaviour on failed KeyAuth check – HTTP 401 Unauthorized
But Echo returns HTTP 500 Internal server error.

Do I do something wrong?
Or it is an issue, that needed improvement/fix?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions