This repository was archived by the owner on Apr 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
Update backend-only var and auth docs w.r.t. app security #1348
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,25 @@ | ||
| ```python exec | ||
| from pcweb.pages.docs import vars | ||
| ``` | ||
|
|
||
| # Authentication Overview | ||
|
|
||
| Many apps require authentication to manage users. There are a few different ways to accomplish this in Reflex: | ||
|
|
||
| We have solutions here: | ||
| We have solutions that currently exist outside of the core framework: | ||
|
|
||
| 1. Local Auth: Uses your own database: https://github.com/reflex-dev/reflex-examples/tree/main/twitter | ||
| 2. Google Auth: Uses sign in with Google: https://reflex.dev/blog/2023-10-25-implementing-sign-in-with-google/ | ||
| 1. Local Auth: Uses your own database: https://github.com/masenf/reflex-local-auth | ||
| 2. Google Auth: Uses sign in with Google: https://github.com/masenf/reflex-google-auth | ||
| 3. Captcha: Generates tests that humans can pass but automated systems cannot: https://github.com/masenf/reflex-google-recaptcha-v2 | ||
| 4. Magic Link Auth: A passwordless login method that sends a unique, one-time-use URL to a user's email: https://github.com/masenf/reflex-magic-link-auth | ||
| 5. Clerk Auth: A community member wrapped this component and hooked it up in this app: https://github.com/TimChild/reflex-clerk-api | ||
|
|
||
| ## Guidance for Implementing Authentication | ||
|
|
||
| - Store sensitive user tokens and information in [backend-only vars]({vars.base_vars.path}#backend-only-vars). | ||
| - Validate user session and permissions for each event handler that performs an authenticated action and all computed vars or loader events that access private data. | ||
| - All content that is staticly rendered in the frontend (for example, data hardcoded or loaded at compile time in the UI) will be publicly available, even if the page redirects to a login or uses `rx.cond` to hide content. | ||
| - Only data that originates from state can be truly private and protected. | ||
| - When using cookies or local storage, a signed JWT can detect and invalidate any local tampering. | ||
|
|
||
| More auth documentation on the way. Check back soon! | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.