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

Support concurrent CSRF cookies by using a prefix of nonce #178

Closed
wants to merge 2 commits into from

Conversation

mwitkow
Copy link

@mwitkow mwitkow commented Sep 3, 2020

This addresses the problem of multiple login requests (with different nonces in state) rewriting the same CSRF cookie.
It provides a unique cookie per request by suffixing the CSRF cookie name with the first 6 characters of the nonce, e.g. _forward_auth_csrf_986711.

This should address #176 and #113

I've verified that it works in my local setup, and addresses the issue of using Traefik Forward Auth in front of single page apps such as Home Assistant.

@thomseddon thomseddon added the bug Something isn't working label Sep 3, 2020
Copy link
Owner

@thomseddon thomseddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, really nice implementation, thank you!

I've requested a slight tweak here, please could you also add some regex checks on the cookie name in the TestAuthMakeCSRFCookie test?

internal/auth.go Outdated Show resolved Hide resolved
Copy link
Author

@mwitkow mwitkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments.

internal/auth.go Outdated Show resolved Hide resolved
@markthebault
Copy link

Hi, I am also experiencing this issue, if there any blocker to merge this PR ?

@thomseddon
Copy link
Owner

Merged in #187 (with some a couple of extra tests)

Thanks so much for this, and for the blog posts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants