Skip to content

ENG-8753 docs: add enterprise auth documentation section#6672

Open
FarhanAliRaza wants to merge 11 commits into
reflex-dev:mainfrom
FarhanAliRaza:auth-docs
Open

ENG-8753 docs: add enterprise auth documentation section#6672
FarhanAliRaza wants to merge 11 commits into
reflex-dev:mainfrom
FarhanAliRaza:auth-docs

Conversation

@FarhanAliRaza

Copy link
Copy Markdown
Contributor

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:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?

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.
@FarhanAliRaza FarhanAliRaza requested review from a team and Alek99 as code owners June 19, 2026 22:42
@codspeed-hq

codspeed-hq Bot commented Jun 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing FarhanAliRaza:auth-docs (cb304f4) with main (8b56f52)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a complete enterprise authentication documentation section covering the rxe.AuthPlugin OIDC integration, registering six new pages and wiring them into the enterprise sidebar and overview.

  • New auth docs: overview, secure-by-default, providers, custom-pages, testing, and deployment pages document the full lifecycle of OIDC auth in Reflex Enterprise, including the secure-by-default model, authorization checks, provider subclassing, custom page builders, unit-testing patterns, and production deployment requirements.
  • Sidebar and overview updated: The new pages are registered in the enterprise sidebar under a new "Authentication" group and listed in the enterprise/overview.md feature table with correct counts and links.
  • Whitelist correctly reset: WHITELISTED_PAGES is empty, ensuring the full docs site builds; an earlier dev-only non-empty state was reverted in a prior commit on this branch.

Confidence Score: 4/5

Safe to merge after fixing one broken code snippet in the providers page.

The UserInfo TypedDict example in providers.md references rx.State without importing reflex as rx, so the snippet fails with a NameError for anyone who copies it verbatim. All other docs pages have correct imports and accurate cross-links. The whitelist is correctly empty.

docs/enterprise/auth/providers.md — the UserInfo TypedDict code block at line 263 is missing import reflex as rx.

Important Files Changed

Filename Overview
docs/app/reflex_docs/whitelist.py Whitelist is correctly reset to an empty list (WHITELISTED_PAGES = []), building all pages; the dev-only non-empty state from an earlier commit was reverted in commit 34b71c8.
docs/enterprise/auth/overview.md New AuthPlugin overview covering quickstart, four protected surfaces, reading the current user, signing out, and the login flow; cross-links are consistent and prose is accurate.
docs/enterprise/auth/secure-by-default.md Thorough coverage of the auth= API (bool/callable), page/event/field/var surfaces, authorization checks, context objects, CSRF logout protection, and the User facade; imports in all code snippets are correct.
docs/enterprise/auth/providers.md Covers GenericOIDCAuthState, named providers, environment variables, scopes, multi-provider setups, hooks, and token access; the UserInfo TypedDict snippet at line 263 is missing import reflex as rx, causing a NameError for copy-pasters.
docs/enterprise/auth/custom-pages.md Documents the page-builder contract for login, callback, logout, and forbidden pages with examples, auth-failure UX, and wiring instructions; content is accurate and well-structured.
docs/enterprise/auth/testing.md Testing guide covers unit-testing auth checks with hand-built contexts, async checks with @pytest.mark.asyncio, and end-to-end mock-IdP flows with oidc-provider-mock and Playwright.
docs/enterprise/auth/deployment.md Deployment guide covering HTTPS requirements, callback URL registration, reverse proxy/multi-replica behaviour, IdP-specific examples, and a troubleshooting table.
docs/enterprise/overview.md Adds an Authentication category (6 entries, count=6) with correct links to the new auth docs pages alongside the existing categories.
docs/app/reflex_docs/templates/docpage/sidebar/sidebar_items/enterprise.py Adds a new Authentication sidebar section with 6 entries; structure is consistent with the rest of the file.

Reviews (9): Last reviewed commit: "Merge branch 'main' into auth-docs" | Re-trigger Greptile

Comment thread docs/app/reflex_docs/whitelist.py Outdated
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.
@adhami3310 adhami3310 added the documentation Improvements or additions to documentation label Jun 24, 2026
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.
Comment on lines +381 to +384
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:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sentence is kind of confusing; sounds like you make openfga checks with get_state... but that function is only for accessing other states

Comment on lines +392 to +395
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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't love this example, but we should at the least be using a backend var for anything related to auth checks

@masenf masenf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /login and display the palette rather than rendering provider-specific login buttons themselves.
  • 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.

FarhanAliRaza and others added 4 commits June 26, 2026 18:40
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants