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

Document AMP CSRF solution #9471

Closed
ericlindley-g opened this issue May 22, 2017 · 9 comments
Closed

Document AMP CSRF solution #9471

ericlindley-g opened this issue May 22, 2017 · 9 comments

Comments

@ericlindley-g
Copy link
Contributor

I've gotten the question a couple times as to whether AMP supports CSRF tokens — it would be great to clearly articulate in the amp-form documentation how CSRF is handled, and why tokens are not needed.

/cc @aghassemi

@wgv-sethlivingston
Copy link

So they're not needed? Is it because of the requirements that are already in place for amp-form and the action-xhr attribute?

@molnarg
Copy link

molnarg commented Oct 2, 2017

See this documentation: https://github.com/ampproject/amphtml/blob/master/spec/amp-cors-requests.md#verify-state-changing-requests The same page is also there somewhere on the official website somewhere.

@wgv-sethlivingston
Copy link

Definitely not clear there whether they are required. :)

@ericlindley-g
Copy link
Contributor Author

/cc @bpaduch

@ericlindley-g ericlindley-g assigned ghost and unassigned ericlindley-g Jan 5, 2018
@ericlindley-g ericlindley-g removed this from Backlog (shortlist) in UI Jan 5, 2018
@ghost
Copy link

ghost commented Feb 22, 2018

will look @ in: Q2

@ghost ghost added this to Q2+ in Documentation Feb 22, 2018
@ghost ghost moved this from Q2 to Backlog in Documentation Feb 22, 2018
@ericlindley-g
Copy link
Contributor Author

Thanks! /cc @lswang1618 as she might have more insight into what e-comm developers need in this area

@cvializ
Copy link
Contributor

cvializ commented Apr 10, 2018

AMP will need to add functionality to amp-form to enable XSRF token support, since XSRF tokens are usually added to forms by the server rendering the HTML, which does not work for AMP since the document will be cached. So the token needs to be requested and rendered into the form by AMP.

This CSRF token feature has been partially spec'd and will be necessary to allow file upload (#9791) and password fields (#10902) in non-XHR forms.

@jean-felipe
Copy link

Some update about enable CSRF token in forms? I use Rails as backend and for security we need that CSRF token to be send on parameters, but this token should be the same as <meta name="csrf-token" content="token=="> if you could add this to amp-form or tell me a way to get this token from meta tag.

@ghost ghost removed this from Backlog in Documentation Aug 2, 2018
@ghost ghost assigned CrystalOnScript and unassigned ghost Aug 8, 2018
@aghassemi
Copy link
Contributor

https://amp.dev/documentation/guides-and-tutorials/learn/amp-caches-and-cors/amp-cors-requests#restrict-requests-to-source-origins covers this.

Essentially there is no need for a CSRF token, checking request origin and __amp_source_origin in XHR post is enough.

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

No branches or pull requests

7 participants