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

add :strategy option and protocol to middleware #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrisbetz
Copy link

@chrisbetz chrisbetz commented Jan 29, 2018

Hi,

I'm not sure whether you're interested in this PR or not ... it's almost the same (and made for the same reasons) as the one on ring-anti-forgery.

As this library is much more "isolated", I could move forward with my own fork, it's completely up to you.

Yes, there still are some whitespace issues... I'm removing them by hand (as my tooling has different defaults obviously) if you're interested. Just let me know.


This change is Reviewable

This allows other CSRF-protection strategies to be employed.
@weavejester
Copy link
Owner

Sorry, can you explain the purpose of this PR? It looks like you've just copied the code from the anti-forgery middleware, but I don't understand why.

@chrisbetz
Copy link
Author

Ah, sorry, my fault: I'm so deep into that right now I'm not aware that the requirements are not obvious ;) Yes, it's almost (unfortunately not exactly) a copy of the protocol from ring-anti-forgery.

Reason is, the state parameter in the OAuth flow is just a CSRF-protection. Thus, the same requirements here lead to a similar (but not exactly identical) solution: Again: Introducing other strategies will allow for implementations without server state.

It's not exactly the same, as we need the profile/id.

Hope this clarifies things.

Cheers,

Chris

@weavejester
Copy link
Owner

What use is this when the OAuth access token needs to be stored across state anyway?

@chrisbetz
Copy link
Author

chrisbetz commented Jan 29, 2018 via email

@weavejester
Copy link
Owner

weavejester commented Jan 29, 2018

  • if you fetch all the data required immediately in the success handler.

Where are you going to store that data? Or are you saying that the success handler would just do whatever it needs to do, and then just discard the access token and any other user data?

  • alternatively, you need to store it in a DB or another persistent storage (again, without the need of in-memory server state).

A session doesn't need to be in-memory, and it usually isn't in production because that wouldn't work behind a load balancer.

@chrisbetz
Copy link
Author

chrisbetz commented Jan 29, 2018 via email

@weavejester
Copy link
Owner

I'll think about this, but my initial reaction is that this adds too much complexity for what seems like a fairly uncommon use case. It's possible to use OAuth entirely statelessly, but my guess is that most of the time applications going to be persisting at least some state across requests, either stored on the server, or via a cookie. In such cases, there seems no advantage to avoiding sessions.

@chrisbetz
Copy link
Author

chrisbetz commented Jan 29, 2018 via email

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.

2 participants