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

Changed to use token: Spree.api_key #792

Merged
merged 2 commits into from
Feb 18, 2016
Merged

Changed to use token: Spree.api_key #792

merged 2 commits into from
Feb 18, 2016

Conversation

sanchojaf
Copy link
Contributor

authenticity_token: AUTH_TOKEN by token: Spree.api_key

authenticity_token: AUTH_TOKEN by token: Spree.api_key
@jhawthorn
Copy link
Contributor

These aren't the same thing. AUTH_TOKEN/authenticity_token is the form_authenticity_token, token/Spree.api_key is a key for the api.

Spree.ajax will already send an API key (via the X-Spree-Token header).

Is there an issue this is attempting to solve?

@sanchojaf
Copy link
Contributor Author

Hi

I had several issues in my migration from spree to solidus with

authenticity_token: AUTH_TOKEN, with different methods.

I added this comment in solidus slack channel:

Do you have any recommendation, when should be used in JS for authorization:
token: Spree.api_key
instead of
authenticity_token: AUTH_TOKEN

In the backend (not only for the API) both approaches are used, looks like some authenticity_token: AUTH_TOKEN in Spree are now 'token: Spree.api_key', but not all have been changed, then I am not clear if I have to use one over the other in some contexts

One of the answer was:

gmacdougall [10:49 AM] miguel: Spree.api_key is preferred
I don't know if the other one still works at all

I reviewed and I found only 3 place where is keep used
authenticity_token: AUTH_TOKEN
I suppose that is an issue.

@cbrunsdon
Copy link
Contributor

@sanchojaf without this change whats the actual error you're experiencing? some kind of CSRF error? are you able to write a spec that would fail without the change in it? I'm also having a hard time understanding why we want to change this.

@cbrunsdon
Copy link
Contributor

Hey @sanchojaf, I looked into this a bit more and talked with @jhawthorn IRL to give me a bit of background.

The Spree.ajax call should already append the Spree.api_key as the token:, so I think to achieve your fix all you should need to do is remove the authenticity_token without also adding the token.

If you can update your PR to do just that I'd be 👍 on it.

@sanchojaf
Copy link
Contributor Author

Thanks @cbrunsdon for your feedback. I updated the pull request. Thanks.

@cbrunsdon
Copy link
Contributor

Cool, this is good by me now, thanks @sanchojaf 👍

jhawthorn added a commit that referenced this pull request Feb 18, 2016
Changed to use token: Spree.api_key
@jhawthorn jhawthorn merged commit cbd707a into solidusio:master Feb 18, 2016
@jhawthorn
Copy link
Contributor

Thanks @sanchojaf

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

Successfully merging this pull request may close these issues.

None yet

3 participants