Skip to main content

rustauth_plugins/oauth_proxy/
mod.rs

1//! OAuth proxy plugin.
2
3mod endpoint;
4mod hooks;
5mod options;
6mod payload;
7mod utils;
8
9use rustauth_core::plugin::AuthPlugin;
10
11pub use options::{OAuthProxyOptions, OAuthProxyOptionsBuilder};
12
13pub const UPSTREAM_PLUGIN_ID: &str = "oauth-proxy";
14
15#[must_use]
16pub fn oauth_proxy(options: OAuthProxyOptions) -> AuthPlugin {
17    AuthPlugin::new(UPSTREAM_PLUGIN_ID)
18        .with_version(crate::VERSION)
19        .with_options(options.to_value())
20        .with_endpoint(endpoint::oauth_proxy_callback_endpoint(options.clone()))
21        .with_async_before_hook("/sign-in/social", hooks::before_sign_in(options.clone()))
22        .with_async_after_hook("/sign-in/social", hooks::after_sign_in(options.clone()))
23        .with_async_before_hook("/sign-in/oauth2", hooks::before_sign_in(options.clone()))
24        .with_async_after_hook("/sign-in/oauth2", hooks::after_sign_in(options.clone()))
25        .with_async_before_hook("/callback/:id", hooks::before_callback(options.clone()))
26        .with_after_hook("/callback/:id", hooks::after_callback(options))
27}