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

Let CSRF Token Be Available #2523

Closed
zmetcalf opened this issue Mar 2, 2018 · 3 comments
Closed

Let CSRF Token Be Available #2523

zmetcalf opened this issue Mar 2, 2018 · 3 comments
Assignees
Labels

Comments

@zmetcalf
Copy link

zmetcalf commented Mar 2, 2018

I am not sure if this is an issue or just a lack of understanding on my part, but the CRAFT_CSRF_TOKEN cookie is set as httpOnly on this line:

'httpOnly' => true

after being called from here:

$request->csrfCookie = Craft::cookieConfig([], $request);

Should this cookie be hidden from JavaScript? If it isn't available to JavaScript, why is it there?

@zmetcalf
Copy link
Author

zmetcalf commented Mar 2, 2018

Also, as a follow up question, is there a better way to force the session other than putting the {{ csrfInput()}} in the template? (re: #1765)

@angrybrad
Copy link
Member

Should this cookie be hidden from JavaScript?

Yes, by default. It's reduces attack surface and most installs don't need access to it from JS.

If you have an explicit need where you need to, you can override component behavior in craft/config/app.php.

is there a better way to force the session other than putting the {{ csrfInput()}} in the template?

You can use `{{ craft.app.session.open() }}

@zmetcalf
Copy link
Author

zmetcalf commented Mar 6, 2018

Thank you @angrybrad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants