ENG-8753 docs: add enterprise auth documentation section#6672
ENG-8753 docs: add enterprise auth documentation section#6672FarhanAliRaza wants to merge 11 commits into
Conversation
Add docs for the OIDC AuthPlugin covering the secure-by-default model, providers, custom auth pages, and testing guarded code. Register the new pages in the enterprise sidebar, add an Authentication category to the enterprise overview, and whitelist the section for preview.
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryThis PR adds a complete enterprise authentication documentation section covering the
Confidence Score: 4/5Safe to merge after fixing one broken code snippet in the providers page. The docs/enterprise/auth/providers.md — the UserInfo TypedDict code block at line 263 is missing Important Files Changed
Reviews (9): Last reviewed commit: "Merge branch 'main' into auth-docs" | Re-trigger Greptile |
Document that User.name/.email/.sub/.picture resolve against AuthUserState — populated after login by whichever provider authenticated the user — so they work in single- and multi-provider setups alike, rather than the first configured provider. Correct their type from `str | None` to `str` (empty until login) and note AuthUserState.provider_name / User.current_provider() for branching on the active provider.
Add a new "Deploying to Production" page covering the HTTPS/Secure-cookie requirement, exact redirect URI construction, reverse-proxy origin handling, and a troubleshooting reference keyed on literal errors. Wire it into the enterprise sidebar, overview listing, and docs whitelist. Revise the existing auth pages (overview, secure-by-default, providers, custom-pages, testing) for accuracy and depth.
…m-pages Point the logout-flow descriptions at the secure-by-default section that documents the cross-site logout guard, so readers can find the guarantee from where logout is first mentioned.
Drop the auth-docs preview entries now that the section is complete; an empty whitelist builds the full site, matching upstream behavior.
Clarify that the app compiles before the IdP is reachable (discovery happens at login), that auth= checks attach to specific events/vars/ fields, and tighten the testing guide: run from tests/, the _userinfo/userinfo split, and a full Playwright OIDC end-to-end example.
| An async check can reach **any other state**, a database, or a remote | ||
| authorization service (e.g. OpenFGA / a ReBAC backend) via | ||
| `await ctx.auth_user_state.get_state(...)` — the round-trip a sync check can't | ||
| make: |
There was a problem hiding this comment.
this sentence is kind of confusing; sounds like you make openfga checks with get_state... but that function is only for accessing other states
| class PolicyState(rx.State): | ||
| """A sibling state (or a stand-in for a DB / authz service).""" | ||
|
|
||
| admin_group: rx.Field[str] = rxe.field("admins", auth=False) |
There was a problem hiding this comment.
i don't love this example, but we should at the least be using a backend var for anything related to auth checks
masenf
left a comment
There was a problem hiding this comment.
i dont really like the overall tone of the docs, it reads as very LLMish.
Stuff like this is particularly bad:
- "The plugin auto-installs middleware that blocks cross-site GET navigations to /logout — using the browser-set, JS-unspoofable Sec-Fetch-Site header — so an attacker's <iframe> can't silently log the user out (it is redirected to the frontend root before the SPA boots)"
- "User is an alias of AuthUserState; you can read claims off either name."
- the part after the semicolon is obvious if it's an alias, we don't need to patronize our readers. The sentence could be improved by saying "User is an alias of reflex_enterprise.auth.AuthUserState and may be used interchangeably"
- "This page covers the default provider, naming your own, the environment variables each one reads, registering providers with the plugin, scopes and refresh tokens, running several providers at once, the claims they return, and the advanced hooks you can override."
- No one wants to read a long running inline list. Either bullet or remove. The headings are visible on the right anyway, so the user knows what to expect on this page.
- "Render a login button for the provider with its get_login_button() classmethod (pass children to customize the clickable element):"
- This seems like it should maybe be under the customization section, feels kind of out of place on the OIDC provider page, especially because we would prefer them to redirect to
/loginand display the palette rather than rendering provider-specific login buttons themselves.
- This seems like it should maybe be under the customization section, feels kind of out of place on the OIDC provider page, especially because we would prefer them to redirect to
- The dash then rephrasing what was obviously stated is an annoying LLMism. These should be rephrased more like reference material, not like an LLM explaining/justifying a PR.
- "When the app detects it is embedded in an iframe, login and logout automatically switch from a top-level redirect to a popup window with a postMessage token hand-off — so a Reflex auth app embeds inside another product with no extra configuration. "
- "This auto-switch only works through the provider's get_login_button() — it mounts the message listener that receives the tokens posted from the popup"
idk i could keep going, but my recommendation is to have your agent reword a lot of this material to be less conversational and LLMish and moreso fit the tone of reference documentation.
Editorial pass over the enterprise auth pages: shorter sentences, fewer em-dash asides, and a consistent "Related" link format. Drop User.provider_name from the documented frontend Vars (use User.sub != "" for signed-in checks) and note that ctx.auth_user_state.provider exposes the provider class to backend checks. Lead the authorization-check guidance with sync checks and present async as the option for DB / remote / state-dependent checks.
Spell out that rxe.event, rxe.field, and rxe.var accept all three auth= values while rxe.page takes a bool only, replacing the prose that implied every wrapper shared identical semantics.
Add docs for the OIDC AuthPlugin covering the secure-by-default model, providers, custom auth pages, and testing guarded code. Register the new pages in the enterprise sidebar, add an Authentication category to the enterprise overview, and whitelist the section for preview.
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features: