autumn_plugin_san_mateo/lib.rs
1//! San Mateo plugin for autumn-web.
2//!
3//! The plugin installs San Mateo into an autumn app with one call. San Mateo
4//! keeps OAuth tokens and API keys, refreshes tokens, sends authorized calls
5//! through a proxy, and runs syncs and actions.
6//!
7//! - **API:** the San Mateo REST API under a route prefix (default
8//! `/san-mateo`). autumn lists the routes in `autumn routes`.
9//! - **Config:** the `[san_mateo]` section. It holds env var names, never
10//! secrets.
11//! - **State:** [`SanMateoService`] gives handlers and jobs the service.
12//! - **Operations:** a `san_mateo` health indicator, background loops, and a
13//! drain at shutdown.
14//!
15//! Notes:
16//!
17//! - autumn needs one or more routes of the app. The nested San Mateo router
18//! does not count.
19//! - With `[security.csrf] enabled = true`, add the prefix to `exempt_paths`.
20//! San Mateo clients send tokens, not cookies. Else the startup fails and
21//! the error gives the fix.
22//! - The hosted connect page needs `[security.headers.csp_nonce]
23//! enabled = true`. The plugin then puts the autumn nonce in the page.
24//! - At the root prefix (`"/"`), the plugin merges its router. `autumn routes
25//! audit` cannot prove a merged router, so the audit reports it.
26//! - The background loops start in the startup hook, in roles that run
27//! workers. When `san-mateo-harvest` runs the syncs, set
28//! `[san_mateo.background] run_syncs = false`. Else each sync runs two
29//! times.
30//! - With `.service(san)`, the `server_url` of `san` must end with the
31//! prefix. Else OAuth callbacks give 404. The plugin logs a warning.
32//!
33//! The `autumn_app` example (`examples/autumn_app`) is a full app that you
34//! can run.
35//!
36//! ```rust,no_run
37//! use autumn_plugin_san_mateo::SanMateoPlugin;
38//!
39//! # async fn demo() {
40//! autumn_web::app()
41//! .plugin(SanMateoPlugin::new().prefix("/san-mateo"))
42//! .run()
43//! .await;
44//! # }
45//! ```
46
47pub mod config;
48mod error;
49mod health;
50mod plugin;
51mod routes;
52mod runtime;
53mod service;
54#[cfg(test)]
55mod test_support;
56
57pub use config::SanMateoConfig;
58pub use error::PluginError;
59pub use health::{INDICATOR_NAME, SanMateoHealth};
60pub use plugin::{
61 AUTUMN_WEB_REQUIREMENT, DEFAULT_PREFIX, PLUGIN_NAME, SanMateoPlugin, SanMateoRuntime,
62 plugin_contract,
63};
64pub use san_mateo;
65pub use service::{SanMateoService, autumn_error};