1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! A [Seamless Auth](https://github.com/fells-code/seamless-auth-api) server adapter for Axum.
//!
//! The adapter sits in front of the Seamless Auth API. Browsers talk to it over
//! `HttpOnly` cookies on the application's own domain, native clients over bearer
//! tokens, and it talks to the auth API over bearer tokens and a service token.
//! Which routes it serves, and what each does to the session, comes from the auth
//! API's adapter manifest.
//!
//! ```no_run
//! use axum::{Json, Router, routing::get};
//! use seamless_auth::{Adapter, User};
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let auth = Adapter::builder(std::env::var("AUTH_SERVER_URL")?)
//! .cookie_secret(std::env::var("COOKIE_SECRET")?)
//! .service_secret(std::env::var("SERVICE_SECRET")?)
//! .jwks_kid(std::env::var("JWKS_KID")?)
//! .build()?;
//!
//! let app: Router = Router::new()
//! .route(
//! "/api/me",
//! get(|user: User| async move { Json(serde_json::json!({ "id": user.id })) })
//! .route_layer(auth.require_auth()),
//! )
//! .nest("/auth", auth.router());
//!
//! let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
//! axum::serve(
//! listener,
//! app.into_make_service_with_connect_info::<std::net::SocketAddr>(),
//! )
//! .await?;
//! # Ok(())
//! # }
//! ```
pub use Adapter;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;