Expand description
Cadmus: a batteries-included web framework for axum and SeaORM.
Register SeaORM entities as models and the crate serves admin pages (list, search,
create, edit, delete) and REST endpoints for each one, behind accounts with permissions,
and keeps their tables up to date with migrations. A project is configured with one
Settings value (see settings) and App::from_settings; the pieces below can also
be put together by hand. Look and feel
(UiSettings) and authentication (AuthConfig, EnvUserStore) can be configured
entirely from environment variables.
ⓘ
let admin = Admin::builder()
.settings(UiSettings::from_env()?)
.auth(AuthConfig::from_env()?, EnvUserStore::from_env()?)
.register(SeaOrmResource::<post::Entity>::new(db.clone()))
.build()?;
let app = axum::Router::new().merge(admin.router());Re-exports§
pub use settings::Settings;pub use settings::Theme;pub use settings::UiSettings;
Modules§
- file
- The
storage_fileentity: one stored file. - group
- The
auth_groupentity: a named set of permissions that accounts can be put in. - identity
- The
auth_identityentity: which account each login through another site belongs to. - migrations
- Versioned migrations.
- session
- The
storage_uploadentity: one resumable upload in progress. - settings
- Settings: the whole project’s configuration (
Settings), and the look of the admin (UiSettings). - user
- The
auth_userentity.
Structs§
- Access
- What one account may do. Returned by
crate::UserStore::accessfor every request. - Admin
- A configured admin panel. Create with
Admin::builder, mount withAdmin::router. - Admin
Builder - Builder for
Admin. - Admin
User - An account allowed into the admin.
- ApiError
- An
AdminErroranswered as JSON:{"error": {"code", "message", "field"}}. - ApiKey
Owner - The account an API key belongs to, as
UserStore::api_keyfinds it. - App
- An application: register models, add your own routes, then call
App::run. - Auth
Config - Authentication settings. Build in code, or load with
AuthConfig::from_env. - DbUser
Store UserStorebacked by theauth_usertable. Only active staff accounts are returned.- Docs
Config - Settings for the API documentation. Build in code, or load with
DocsConfig::from_env. - One message to one person.
- EnvUser
Store - A single admin account defined by environment variables.
- Field
- Metadata for one column of a model.
- Filter
- One condition on a column, as
?published=trueor?created_at__gte=2026-01-01asks. - Home
Config - Settings for the home page. Build in code, or load with
HomeConfig::from_env. - List
Query - A page request for
Resource::list. - LogMailer
- Writes each message to the log instead of sending it: for development, where the login
links can be copied from the terminal. This is what a site without
mail.urluses. - Model
Options - How a model appears in the admin: list columns, search, filters, read-only and hidden fields, actions and more.
- Page
- One page of rows plus the total match count.
- Reference
- What a foreign-key column points to.
- SeaOrm
Resource - Admin resource backed by a SeaORM entity.
- Sink
- A streaming write of unknown length.
- Smtp
Mailer - Sends messages through an SMTP server.
- Storage
- A storage backend plus the key prefix this app writes under.
- Uploads
- The upload service: storage backend, database and limits.
Enums§
- Action
- Something an account can be allowed to do to a model.
- Admin
Error - Everything that can go wrong while configuring or serving the app.
- Field
Kind - How a field is rendered and parsed.
- Filter
Op - How a
Filtercompares the column with its value. - Progress
- Result of appending a chunk.
- Write
Mode - How
Resource::updatetreats columns that are missing from the input.
Traits§
- Mailer
- Something that delivers
Emails. - Resource
- A model the admin can list and edit.
- User
Store - Where admin accounts come from. Implement this over your own users table;
EnvUserStorecovers the single-operator case.
Functions§
- change_
password - Replaces an account’s password.
- create_
superuser - Creates an active superuser: an account that may do everything, including managing other accounts.
- disable_
totp - Turns two-factor authentication off for an account, e.g. after its device was lost.
- enable_
totp - Turns two-factor authentication on for an account, replacing any earlier secret, and
returns the new base32 secret to put into an authenticator app (see
crate::totp_uri). - hash_
password - Hashes a password with Argon2id for storage in
ADMIN_PASSWORD_HASHor your users table. - hash_
password_ async hash_passwordon the blocking thread pool, for use from async code.- new_
api_ key - Creates an API key for an account and returns it. It is shown once: only its digest is
stored. The key acts as the account, with the account’s permissions (only reading, if
read_only), until it is revoked,expires_in_dayspass, or the account is deactivated. What theapikeycommand does. - new_
recovery_ codes - Replaces an account’s two-factor recovery codes with a new set of ten and returns them, to
be shown once: each logs in once in place of an authenticator code. What the
totpcommand prints after turning two-factor authentication on. - promote
- Makes an existing account an active superuser, keeping its password.
- set_
email - Sets the e-mail address of an account, e.g. after
createsuperuser --email. - totp_
uri - The
otpauth://address an authenticator app reads from a QR code.issueris the name the app shows next to the account, usually the site’s title. - verify_
totp - Verifies an RFC 6238 code (SHA-1, 6 digits, 30 s step), accepting one step of clock drift either way.