-
Notifications
You must be signed in to change notification settings - Fork 336
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
auth token handling in preparation for socketization #77
Comments
I'm super-glad I pulled down your latest changes and stepped through the new Cashay-enabled/cached authentication. I think I actually have an informed opinion to share :) I think it's safe to consider authentication as domain state, as the token is just data originated from a different backend. I vote for (#1) Cashay (persist automatically using redux-persist) Pros:
Cons:
Alternatively, I could see (#4) Fetch + put in redux (persist automatically using redux-persist) being a good option. Imagine:
Only thing is with #4, I think it'd still make sense for us to use our I'm fine with either! |
really good input! Currently, 1 is closest to how we have it set up right now, but when i started writing local-only mutations solely for the AuthEngine, I started to question myself. It's a great option for us. 4 is an interesting one because we actually get the tl;dr: |
Yeah, either 1 or 4. Be interesting to see what you end up going with! |
4 is definitely cleaner for our immediate use. are you thinking about staying with auth0 for the life of the project? |
For now, there aren't any immediate plans to switch away. It depends on business needs. |
hmm, then i say let's go for 4. Friendlier codebase, easier to understand. |
This will be closed by #82, correct? |
yep, i think that's a good stopping point for the welcome-ui branch, will keep the |
👍 |
Merged to |
Issue - Enhancement
Cashay is ready to test for subs, but before we support subs, we need to come up with a good pattern for sharing the auth token between socketCluster, cashay, redux, and localStorage/localForage/reduxNativeStorage.
Auth tokens are tricky beasts because they don't live in the database, although they do come from the server. I'm not sure whether it's considered local state or domain state because it can't be generated on the client, but it can be invalidated on the client (ie validate expiration). In our particular case, we don't need it to come from our GraphQL server, but in doing so, we establish a pattern that does not depend on auth0.
So, assuming the authToken comes from our GraphQL server, we have a few options:
redux-persist
transform, application-specific AuthEngine for socketCluster, and addinglocalOnly
option to cashay__CLIENT__
conditionals for SSR, the token is stored in 2 locations (redux, local state), requires application-specific logic to expire/refresh each location__CLIENT__
conditionals for SSR, authToken is handled outside of GraphQL, lots of code to rewrite when we switch tolocalForage
or reactive native storageredux-persist
transform, AuthEngine for socketCluster, authToken is handled outside of GraphQLThe options in bold are the ones that I think suck the least, but none are great.
@jordanh any strong feelings or possible alternatives?
The text was updated successfully, but these errors were encountered: