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 custom session strategy example #8552

Merged
merged 12 commits into from
May 8, 2023
Merged

Add custom session strategy example #8552

merged 12 commits into from
May 8, 2023

Conversation

dcousens
Copy link
Member

@dcousens dcousens commented May 5, 2023

This pull request adds a custom session strategy example.
The example shows how to implement a simple session strategy for authentication, using a cookie.

The session strategy, sillySessionStrategy, is a demonstrative example acting as a starting point for implementing your own session strategy. The Cookie:user={user_id} format used in this example should outline the moving parts of an implementation, but it is by no means actual authentication. In practice, you should use actual authentication, such as OAuth or JWT.

You can pass a cookie with the format Cookie:user={id} in your HTTP requests, and the strategy will extract the id from the cookie and look up the corresponding user in the User list. If the user is found, the strategy will return a session object with an id field and an admin flag.

@dcousens dcousens requested a review from borisno2 May 5, 2023 12:36
@dcousens dcousens self-assigned this May 5, 2023
@changeset-bot

This comment was marked as resolved.

@dcousens
Copy link
Member Author

dcousens commented May 5, 2023

Separate to this, which is a rather arbitrary sandbox example that is fun to play with to learn how custom session strategies can work, we should add a custom-session-jwt as a more concrete example.

This pull request will hopefully be simplified and easier with #8097

@codesandbox-ci

This comment was marked as resolved.

@dcousens dcousens merged commit ea227f0 into main May 8, 2023
@dcousens dcousens deleted the custom-session branch May 8, 2023 05:47
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