scufflecloud_core/
lib.rs

1//! Core/Authentication server for <https://scuffle.cloud/>.
2//!
3//! ## Authentication
4//!
5//! TODO
6//!
7//! ## License
8//!
9//! This project is licensed under the [AGPL-3.0](./LICENSE.AGPL-3.0).
10//!
11//! `SPDX-License-Identifier: AGPL-3.0`
12#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
13#![cfg_attr(docsrs, feature(doc_auto_cfg))]
14// #![deny(missing_docs)]
15#![deny(unsafe_code)]
16#![deny(unreachable_pub)]
17// tonic::Status emits this warning
18#![allow(clippy::result_large_err)]
19
20use std::net::SocketAddr;
21
22use diesel_async::AsyncPgConnection;
23use scuffle_batching::DataLoader;
24
25mod captcha;
26pub mod cedar;
27mod chrono_ext;
28mod common;
29pub mod dataloaders;
30mod emails;
31mod google_api;
32mod http_ext;
33pub mod id;
34mod middleware;
35mod models;
36mod operations;
37mod schema;
38pub mod services;
39mod std_ext;
40mod totp;
41
42pub trait CoreConfig:
43    scuffle_bootstrap::Global
44    + scuffle_signal::SignalConfig
45    + scuffle_bootstrap_telemetry::TelemetryConfig
46    + Sync
47    + Send
48    + 'static
49{
50    fn service_name(&self) -> &str;
51    fn bind(&self) -> SocketAddr;
52    fn db(
53        &self,
54    ) -> impl Future<Output = anyhow::Result<diesel_async::pooled_connection::bb8::PooledConnection<'_, AsyncPgConnection>>> + Send;
55    fn authorizer(&self) -> &cedar_policy::Authorizer;
56    fn http_client(&self) -> &reqwest::Client;
57    fn webauthn(&self) -> &webauthn_rs::Webauthn;
58    fn redis(&self) -> &fred::clients::Pool;
59    fn email_service(
60        &self,
61    ) -> pb::scufflecloud::email::v1::email_service_client::EmailServiceClient<tonic::transport::Channel>;
62    fn user_loader(&self) -> &DataLoader<dataloaders::UserLoader>;
63    fn swagger_ui_enabled(&self) -> bool {
64        false
65    }
66    fn dashboard_origin(&self) -> &url::Url;
67    fn turnstile_secret_key(&self) -> &str {
68        "1x0000000000000000000000000000000AA"
69    }
70    fn max_request_lifetime(&self) -> chrono::Duration {
71        chrono::Duration::minutes(2)
72    }
73    fn user_session_timeout(&self) -> chrono::Duration {
74        chrono::Duration::days(30)
75    }
76    fn mfa_timeout(&self) -> chrono::Duration {
77        chrono::Duration::minutes(5)
78    }
79    fn user_session_token_timeout(&self) -> chrono::Duration {
80        chrono::Duration::hours(4)
81    }
82    fn email_registration_request_timeout(&self) -> chrono::Duration {
83        chrono::Duration::hours(1)
84    }
85    fn user_session_request_timeout(&self) -> chrono::Duration {
86        chrono::Duration::minutes(5)
87    }
88    fn magic_link_user_session_request_timeout(&self) -> chrono::Duration {
89        chrono::Duration::minutes(15)
90    }
91    fn google_client_id(&self) -> &str;
92    fn google_client_secret(&self) -> &str;
93    fn email_from_address(&self) -> &str;
94}