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