Skip to main content

grow_oidc/
lib.rs

1// Skeleton created by sdk-kit 0.3.0; owned by this repository (edit freely).
2//! # grow-oidc
3//!
4//! Rust SDK for [OIDC](https://grow-codes-packages.github.io/oidc/) by Grow Codes.
5//!
6//! ```no_run
7//! # async fn demo() -> grow_oidc::Result<()> {
8//! use grow_oidc::{OidcClient, OidcConfig};
9//!
10//! let client = OidcClient::new(OidcConfig::from_env()?)?;
11//! let health = client.health().await?;
12//! println!("healthy: {}", health.healthy);
13//! client.close().await;
14//! # Ok(())
15//! # }
16//! ```
17//!
18//! Features: `blocking` (a blocking client), `testing` (in-memory fakes and the conformance
19//! runner)
20//! .
21#![cfg_attr(docsrs, feature(doc_cfg))]
22
23pub mod core;
24
25mod client;
26mod config;
27mod oidc;
28
29#[cfg(feature = "tower")]
30#[cfg_attr(docsrs, doc(cfg(feature = "tower")))]
31mod oidc_tower;
32
33pub use crate::oidc::{
34    bearer_token, claim_at, extract_roles, has_any_role, AuthUser, ClockFn, Verifier,
35    VerifierOptions, DEFAULT_ALGORITHMS, DEFAULT_CLOCK_SKEW, DEFAULT_HTTP_TIMEOUT,
36    DEFAULT_JWKS_CACHE_TTL, DEFAULT_JWKS_REFRESH_COOLDOWN,
37};
38#[cfg(feature = "tower")]
39pub use crate::oidc_tower::{OidcLayer, OidcService, RequireRolesLayer, RequireRolesService};
40
41#[cfg(feature = "blocking")]
42#[cfg_attr(docsrs, doc(cfg(feature = "blocking")))]
43pub mod blocking;
44
45#[cfg(feature = "testing")]
46#[cfg_attr(docsrs, doc(cfg(feature = "testing")))]
47pub mod testing;
48
49pub use crate::core::{Error, ErrorCode, HealthStatus, Result, RetryPolicy, Secret};
50
51pub use crate::config::DEFAULT_URL;
52
53pub use crate::client::{relative_endpoint, OidcClient, DISCOVERY_PATH};
54
55pub use crate::config::OidcConfig;
56
57pub use crate::config::OidcConfigBuilder;
58
59/// Service-prefixed alias of [`Error`].
60pub type OidcError = Error;