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;
28pub mod storage;
29#[cfg(feature = "testing")]
30pub mod testing;
31pub mod value;
32
33pub use auth::{
34    Api, ApiResponse, Auth, AuthInstance, Builder, ClientAddr, FastAuth, HasPlugin, Missing,
35    NoDatabase, Present,
36};
37pub use error::{AuthError, BuildError};
38#[cfg(feature = "macros")]
39pub use fastauth_macros::{AuthError, Fields, Model};
40pub use hlist::{Append, Cons, Has, Here, Nil, PluginSet, Satisfied, There};
41pub use time::Duration;
42
43/// Everything an app needs to configure auth.
44pub mod prelude {
45    pub use crate::config::{
46        ClientIp, CookieConfig, EmailPassword, EmailVerification, IdStrategy, SameSite, Secure,
47        SessionConfig,
48    };
49    pub use crate::crypto::Secret;
50    pub use crate::events::*;
51    pub use crate::mail::{AuthEmail, LogMailer, Mailer, MemoryMailer};
52    pub use crate::memory::MemoryAdapter;
53    pub use crate::model::Fields;
54    pub use crate::models::{Account, Session, User};
55    pub use crate::rate_limit::{Limit, RateLimit};
56    pub use crate::session::{AuthUser, SessionData};
57    pub use crate::value::Id;
58    pub use crate::{Auth, AuthError, AuthInstance, BuildError, Duration, FastAuth, plugins};
59    #[cfg(feature = "macros")]
60    pub use fastauth_macros::Fields;
61}
62
63/// Everything a plugin author needs.
64pub mod plugin_prelude {
65    pub use std::sync::Arc;
66
67    pub use http::{HeaderMap, Method, StatusCode};
68    pub use serde::{Deserialize, Serialize};
69    pub use time::OffsetDateTime;
70
71    pub use crate::adapter::{Adapter, Order, Transaction};
72    pub use crate::crypto::{Hash, random_string, random_token};
73    pub use crate::endpoint::BoxFuture;
74    pub use crate::endpoint::{
75        After, Authenticated, Before, Ctx, Empty, Endpoint, Fresh, Gate, HookCtx,
76        MaybeAuthenticated, Public, Resolved, SessionResolver, SessionUse, SignInAttempt,
77    };
78    pub use crate::error::{AuthError, ErrorCodes, codes};
79    pub use crate::events::Event;
80    pub use crate::internal::{Claim, NewAccount, NewSession, NewUser, SignInResult, UserInput};
81    pub use crate::model::{Col, Fields, Model, OnTable};
82    pub use crate::models::{Account, Session, User, Verification};
83    pub use crate::plugin::{Plugin, PluginBuilder};
84    pub use crate::query::Where;
85    pub use crate::rate_limit::Limit;
86    pub use crate::schema::{ColumnDef, ColumnType, DefaultValue, OnDelete, SchemaBuilder};
87    pub use crate::session::{SessionView, UserView};
88    pub use crate::value::{ColumnValue, DecodeError, Id, Json, Row, Value};
89    pub use crate::{AuthInstance, Duration, HasPlugin};
90    #[cfg(feature = "macros")]
91    pub use fastauth_macros::{AuthError, Fields, Model};
92}