Skip to content

Failure to provide a csrf token in a form results in error 500 #802

@matteosuppo

Description

@matteosuppo

I secure the app with the csrf middleware:

	e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
		TokenLookup: "form:" + echo.HeaderXCSRFToken,
	}))

and then I make a post request without providing the csrf token.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

I would expect a 400 or 401 error, since it's the client fault that the request failed.

Actual behaviour

I get a 500 error, which is misleading.

Working code to debug

The culprit is here:

return err

It's just returning the error, without wrapping it in an httperror like two lines below

Version/commit

master

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions