Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ilzheev opened this issue Apr 20, 2019 · 1 comment
Closed
Assignees

Comments

@ilzheev
Copy link

ilzheev commented Apr 20, 2019

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?

@ilzheev
Copy link
Author

ilzheev commented Jun 6, 2019

Any updates?

@vishr vishr self-assigned this Jun 9, 2019
@vishr vishr closed this as completed in 842fc87 Jun 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants