Skip to main content

fastauth_core/
lib.rs

1//! The core of [fastauth](https://github.com/lassejlv/fastauth): the builder, the type-level
2//! plugin list, sessions, crypto, routing and the core endpoints. Apps use the `fastauth`
3//! facade crate; adapters, integrations and plugins depend on this one.
4
5pub mod adapter;
6mod auth;
7pub mod config;
8pub mod cookies;
9pub mod crypto;
10#[doc(hidden)]
11pub mod doctests;
12pub mod endpoint;
13pub mod error;
14pub mod events;
15mod hlist;
16pub mod internal;
17pub mod mail;
18pub mod memory;
19pub mod migrate;
20pub mod model;
21pub mod models;
22pub mod plugin;
23pub mod query;
24pub mod rate_limit;
25pub mod routes;
26pub mod schema;
27pub mod session;
28#[cfg(feature = "testing")]
29pub mod testing;
30pub mod value;
31
32pub use auth::{
33    Api, ApiResponse, Auth, AuthInstance, Builder, ClientAddr, FastAuth, HasPlugin, Missing,
34    NoDatabase, Present,
35};
36pub use error::{AuthError, BuildError};
37#[cfg(feature = "macros")]
38pub use fastauth_macros::{AuthError, Fields, Model};
39pub use hlist::{Append, Cons, Has, Here, Nil, PluginSet, Satisfied, There};
40pub use time::Duration;
41
42/// Everything an app needs to configure auth.
43pub mod prelude {
44    pub use crate::config::{
45        ClientIp, CookieConfig, EmailPassword, EmailVerification, IdStrategy, SameSite, Secure,
46        SessionConfig,
47    };
48    pub use crate::crypto::Secret;
49    pub use crate::events::*;
50    pub use crate::mail::{AuthEmail, LogMailer, Mailer, MemoryMailer};
51    pub use crate::memory::MemoryAdapter;
52    pub use crate::model::Fields;
53    pub use crate::models::{Account, Session, User};
54    pub use crate::rate_limit::{Limit, RateLimit};
55    pub use crate::session::{AuthUser, SessionData};
56    pub use crate::value::Id;
57    pub use crate::{Auth, AuthError, AuthInstance, BuildError, Duration, FastAuth, plugins};
58    #[cfg(feature = "macros")]
59    pub use fastauth_macros::Fields;
60}
61
62/// Everything a plugin author needs.
63pub mod plugin_prelude {
64    pub use std::sync::Arc;
65
66    pub use http::{HeaderMap, Method, StatusCode};
67    pub use serde::{Deserialize, Serialize};
68    pub use time::OffsetDateTime;
69
70    pub use crate::adapter::{Adapter, Order};
71    pub use crate::crypto::{Hash, random_string, random_token};
72    pub use crate::endpoint::{
73        After, Authenticated, Before, Ctx, Empty, Endpoint, Fresh, Gate, HookCtx,
74        MaybeAuthenticated, Public, Resolved, SessionResolver, SessionUse, SignInAttempt,
75    };
76    pub use crate::error::{AuthError, ErrorCodes, codes};
77    pub use crate::events::Event;
78    pub use crate::internal::{NewAccount, NewUser, SignInResult};
79    pub use crate::model::{Col, Fields, Model, OnTable};
80    pub use crate::models::{Account, Session, User, Verification};
81    pub use crate::plugin::{Plugin, PluginBuilder};
82    pub use crate::query::Where;
83    pub use crate::rate_limit::Limit;
84    pub use crate::schema::{ColumnDef, ColumnType, DefaultValue, OnDelete, SchemaBuilder};
85    pub use crate::session::{SessionView, UserView};
86    pub use crate::value::{ColumnValue, DecodeError, Id, Json, Row, Value};
87    pub use crate::{AuthInstance, Duration, HasPlugin};
88    #[cfg(feature = "macros")]
89    pub use fastauth_macros::{AuthError, Fields, Model};
90}