iris-contrib / iris-contrib/middleware
CSRF Failing due to Context.Request().URL not containing host
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 239
- Forks
- 89
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Hello,
After playing with CSRF & HTTPS, it seems that Context.Request().URL is not correctly filled, hence failing the referrer check at that line:
valid := sameOrigin(ctx.Request().URL, referer)
To Reproduce
Steps to reproduce the behavior:
- Print the Context.Request().URL.Scheme or .Host when inside a middleware
Expected behavior
We should get part of the URL depending on below schema:
scheme://host.domain:port/path/to/request
actually we're only getting the path part
/path/to/request
Screenshots
see attached screenshot if it helps
ctx.Request().URL showing the path

trying to query ctx.Request().URL.Host

Desktop (please complete the following information):
- Client is running Windows 10,
- Server is running Raspbian 10,
iris.Version
- e.g. v12.2.0-alpha
Additional context
Add any other context about the problem here.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the CSRF referrer check where sameOrigin(ctx.Request().URL, referer) is called, then reproduce the request while inspecting Context.Request().URL.Scheme and Host. Compare the observed URL with the expected scheme://host.domain:port/path/to/request form. Done means the URL contains the information required for the referrer check and the CSRF behavior is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100