feature/smbcloud-cli-release-npm
name: smbcloud-auth
description: Use when building, debugging, or extending smbCloud authentication across the Rails auth service, the web console, the Rust networking SDK, and Tauri client apps. Covers platform clients vs tenant auth apps, AuthUser signup/sign-in/confirmation, shared auth apps across projects, and development vs production app credentials.
smbCloud Auth
Use this skill when work touches any part of the smbCloud auth stack:
smbcloud-apiRails auth servicesmbcloud-web-consoleNext.js admin UIsmbcloud-cli/crates/smbcloud-networking-accountRust SDK- Tauri apps such as Rumi Learn Persian and PBJ Komplit
Core model
There are two auth planes. Do not mix them.
1. Platform clients
These are smbCloud's own apps:
webclisigitmoovibewebconsole
They authenticate smbCloud operator users through platform endpoints such as:
POST /v1/users/sign_inPOST /v1/users
They must use the platform client validator, not tenant app validation.
2. Tenant auth apps
These are customer-facing apps such as Rumi or PBJ Komplit.
They authenticate end users through:
POST /v1/client/usersPOST /v1/client/users/sign_inGET /v1/client/meDELETE /v1/client/meDELETE /v1/client/users/sign_outGET /v1/client/users/confirmation
The tenant auth domain is:
AuthAppAuthAppSecretAuthUser
Tenant apps must use AuthAppClientAuthenticatable and must not go through platform /v1/users.
Multi-project auth apps
Current rule:
- one
AuthApphas an owner project viaauth_apps.project_id - one
AuthAppcan be shared with other projects throughauth_app_projects - one project can point to only one auth app
If a workspace/project should reuse an existing auth app, attach it instead of creating a duplicate.
Rails conventions
When editing smbcloud-api:
- Platform operator auth stays under
User - Tenant app auth stays under
AuthUser - Do not reuse
OauthApplicationfor tenant end-user login - Do not hardcode tenant app validation in platform controllers
AuthUser signup/sign-in rules
- Signup creates an
AuthUserscoped tocurrent_auth_app - Signup sends confirmation email
- Do not auto-set
confirmed_at - Sign-in returns
EmailNotVerifieduntil email is confirmed - Deletion removes the currently authenticated
AuthUser
Mail flow
For tenant users, use the explicit confirmation flow already established:
- custom mailer for
AuthUser - confirmation link to
/v1/client/users/confirmation?confirmation_token=...
Do not claim email confirmation exists unless the mailer and route are actually wired.
Rust SDK conventions
The Rust client surface lives in:
smbcloud-cli/crates/smbcloud-networking-account
When changing tenant app auth:
- keep tenant auth on
/v1/client/* - preserve
AccountStatusmapping:NotFoundReady { access_token }Incomplete { status }
request_logindepends on422+error_codefor incomplete accounts
If the backend changes error shape or status codes, update the Rust parser accordingly.
Tauri client conventions
For Rumi/PBJ-style apps:
- use a dedicated
src-tauri/src/smbcloud/mod.rs - expose commands for:
signup_usersign_in_usercurrent_usersign_out_userdelete_current_useris_debug_build
- store auth state in plugin-store:
- access token
- provider
- auth environment
- language
Environment handling
Keep development and production app credentials separate.
Preferred pattern:
- development credentials for local auth service
- production credentials for hosted auth service
- switch via a Rust
AuthEnvironmentenum - expose the switch in debug builds only
Recommended env variable names:
SMBCLOUD_APP_ID_DEVSMBCLOUD_APP_SECRET_DEVSMBCLOUD_APP_ID_PRODUCTIONSMBCLOUD_APP_SECRET_PRODUCTION
macOS Tauri dev builds
tauri.conf.json minimumSystemVersion is not enough for tauri dev.
For apps that link Swift-based plugins such as tauri-plugin-iap, add src-tauri/.cargo/config.toml with:
MACOSX_DEPLOYMENT_TARGET=14.0-mmacosx-version-min=14.0for both Apple targets- host
CCandCXXoverrides to/usr/bin/clangand/usr/bin/clang++
If you see libswift_Concurrency.dylib at runtime, fix Cargo/macOS config first.
Web console conventions
The admin UI lives in smbcloud-web-console.
Use the Auth area, not generic settings pages, for tenant auth app management.
Expected behavior:
- scope auth view to selected workspace/project
- if workspace has an auth app, show the app and its users
- if not, allow:
- creating a new auth app
- attaching an existing tenant auth app
- show app id in list views
- hide app secret by default on detail views
- show linked/shared workspaces on detail pages
Typical change flow
- Decide whether the change is platform auth or tenant auth.
- Update Rails first.
- Update Rust SDK endpoints/parsing if the API contract changed.
- Update Tauri clients to match.
- Update the web console if auth app management changed.
- Validate end-to-end.
Validation
Use the smallest relevant checks.
Rails
bundle exec rails routes | grep 'v1/client\|auth_apps'ruby -con touched controller/model/mailer filesbundle exec rails db:migrateif schema changed
Rust SDK
cargo check -p smbcloud-networking-account
Tauri apps
cargo checkinsrc-tauripnpm buildin the app root when frontend changed
Web console
pnpm build
Common mistakes
- Sending tenant app credentials to
/v1/users - Using
OauthApplicationinstead ofAuthAppfor tenant login - Replacing platform client validation with tenant auth app validation
- Auto-confirming
AuthUserwhile telling the client to check email - Forgetting that
tauri devignorestauri.conf.jsonmacOS minimum version