oxide_auth/primitives/mod.rs
1//! A collection of primites useful for more than one authorization method.
2//!
3//! A primitive is the smallest independent unit of policy used in OAuth related endpoints. For
4//! example, an `authorizer` generates and verifies Authorization Codes. There only is, as you
5//! might have noticed, only the OAuth2 code grant method. But abstracting away the underlying
6//! primitives makes it possible to provide –e.g.– a independent database based implementation.
7//!
8//! These should be used to build or instantiate an `Endpoint`, for example [`Generic`] or your
9//! own.
10//!
11//! ```
12//! # extern crate oxide_auth;
13//! # use oxide_auth::frontends::simple::endpoint::Vacant;
14//! use oxide_auth::frontends::simple::endpoint::Generic;
15//! use oxide_auth::primitives::{
16//! authorizer::AuthMap,
17//! generator::RandomGenerator,
18//! issuer::TokenMap,
19//! registrar::ClientMap,
20//! };
21//!
22//! Generic {
23//! authorizer: AuthMap::new(RandomGenerator::new(16)),
24//! registrar: ClientMap::new(),
25//! issuer: TokenMap::new(RandomGenerator::new(16)),
26//! // ...
27//! # scopes: Vacant,
28//! # solicitor: Vacant,
29//! # response: Vacant,
30//! };
31//! ```
32//!
33//! [`Generic`]: ../frontends/simple/endpoint/struct.Generic.html
34
35use chrono::DateTime;
36use chrono::Utc;
37use url::Url;
38
39pub mod authorizer;
40pub mod generator;
41pub mod grant;
42pub mod issuer;
43pub mod registrar;
44pub mod scope;
45
46type Time = DateTime<Utc>;
47
48/// Commonly used primitives for frontends and backends.
49pub mod prelude {
50 pub use super::authorizer::{Authorizer, AuthMap};
51 pub use super::issuer::{IssuedToken, Issuer, TokenMap, TokenSigner};
52 pub use super::generator::{Assertion, TagGrant, RandomGenerator};
53 pub use super::registrar::{Registrar, Client, ClientUrl, ClientMap, PreGrant};
54 pub use super::scope::Scope;
55}