feat(examples): per-resource membership authz examples (Dioxus + Leptos)#15
Merged
Conversation
Add dioxus-authz-example and leptos-authz-example — minimal, parallel demos
of arium's per-resource membership axis: an in-memory ResourceAuthority
(role per doc id, registered via AuthConfigBuilder::resource_authority), a
cosmetic ResourceGate that shows/hides the rename field, and a mutation
server fn enforced by require_resource_{dioxus,leptos}. An "Attempt edit
anyway" button on the view-only docs shows the boundary (not the gate) is
what rejects. No OAuth/MFA/mail/tokens, so the membership axis stands alone.
These are the first server/ssr builds WITHOUT mail, which exposed a latent
bug in both adapters: the no-mail register_with_password returned LoggedIn
but never called complete_login/mark_email_verified — so signup left the
caller anonymous and a later sign-in failed as Unverified. Fix both to mark
verified + complete_login. Add a roundtrip assertion that register itself
establishes the session, make each test harness mail-agnostic so it runs
under --no-default-features, and retighten the dead skip_email_verification
gate to all(server/ssr, mail). Harden the harness temp-DB suffix with a
monotonic counter against parallel collisions.
The no-mail examples can't unify with the mail-on fullstack examples in one
workspace build (AuthConfig::builder arity differs by feature), so they're
excluded from the workspace CI test/doc/clippy commands and exercised in
isolation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes the `cargo fmt` CI check. Also drops the stale DX_AUTH_SKIP_EMAIL_VERIFICATION reference from the dioxus example's module doc — a no-op in this no-mail build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Two minimal, parallel examples demonstrating arium's per-resource membership authorization axis — kept apart from everything else (no OAuth/MFA/mail/tokens) so the membership story stands alone:
examples/dioxus-authz-exampleexamples/leptos-authz-exampleEach shows the same three pieces:
DemoAuthority— an in-memoryResourceAuthority(role per doc id, registered viaAuthConfigBuilder::resource_authority). arium stores no memberships; it calls this on every check.ResourceGate— a cosmetic UI gate that shows/hides the rename field.rename_doc— the resource-scoped mutation, enforced byrequire_resource_{dioxus,leptos}(the real boundary). An "Attempt edit anyway" button on the view-only docs proves the server rejects it, gate or no gate.require ≥ Editor)OwnerEditorViewerBug fix surfaced by these examples
These are the first
server/ssrbuilds withoutmail, which exposed a latent bug in both adapters: the no-mailregister_with_passwordreturnedLoginOutcome::LoggedInbut never calledcomplete_login/mark_email_verified— so signup left the caller anonymous and a later sign-in failed asUnverified(UI: "Unexpected sign-in outcome"). Fixed in botharium-dioxusandarium-leptos.Supporting test/infra changes:
tests/common/spawn_appmail-agnostic so the round-trip runs under--no-default-features(verified the fix on the no-mailpath; proved the assertion catches the regression by revertingcomplete_login).skip_email_verificationgate toall(server/ssr, mail).pid+nanos, collided under parallel tests → spurious "duplicate column" migration errors).CI note
The no-
mailexamples can't be unified into one workspace build alongside themail-on fullstack examples (AuthConfig::builderarity differs by feature), so they're--excluded from the workspacecargo test/doc/clippycommands and built in isolation — same treatment as the existing dioxus fullstack example.Verification
arium-{dioxus,leptos}clippy clean in bothmail-on and no-mailconfigs.mailround-trips green.🤖 Generated with Claude Code