mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-28 05:41:34 +00:00
b26aaac523
* Added OAUTH2 OIDC support * Fixes and improvements based on review feedback * use derive_new::new instead of TypedBuilder * merge migrations into a single file * fixes based on review feedback * remove unnecessary hostname_ui config * improvement based on review feedback * improvements based on review feedback * delete user oauth accounts at account deletion * fixes and improvements based on review feedback * removed auto_approve_application * support registration application with sso * improvements based on review feedback * making the TokenResponse an internal struct as it should be * remove duplicate struct * prevent oauth linking to unverified accounts * switched to manually entered username and removed the oauth name claim * fix cargo fmt * fix compile error * improvements based on review feedback * fixes and improvements based on review feedback --------- Co-authored-by: privacyguard <privacyguard@users.noreply.github.com>
69 lines
2.2 KiB
Rust
69 lines
2.2 KiB
Rust
use lemmy_db_schema::newtypes::OAuthProviderId;
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_with::skip_serializing_none;
|
|
#[cfg(feature = "full")]
|
|
use ts_rs::TS;
|
|
use url::Url;
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Create an external auth method.
|
|
pub struct CreateOAuthProvider {
|
|
pub display_name: String,
|
|
pub issuer: String,
|
|
pub authorization_endpoint: String,
|
|
pub token_endpoint: String,
|
|
pub userinfo_endpoint: String,
|
|
pub id_claim: String,
|
|
pub client_id: String,
|
|
pub client_secret: String,
|
|
pub scopes: String,
|
|
pub auto_verify_email: bool,
|
|
pub account_linking_enabled: bool,
|
|
pub enabled: bool,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Edit an external auth method.
|
|
pub struct EditOAuthProvider {
|
|
pub id: OAuthProviderId,
|
|
pub display_name: Option<String>,
|
|
pub authorization_endpoint: Option<String>,
|
|
pub token_endpoint: Option<String>,
|
|
pub userinfo_endpoint: Option<String>,
|
|
pub id_claim: Option<String>,
|
|
pub client_secret: Option<String>,
|
|
pub scopes: Option<String>,
|
|
pub auto_verify_email: Option<bool>,
|
|
pub account_linking_enabled: Option<bool>,
|
|
pub enabled: Option<bool>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Delete an external auth method.
|
|
pub struct DeleteOAuthProvider {
|
|
pub id: OAuthProviderId,
|
|
}
|
|
|
|
#[skip_serializing_none]
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Logging in with an OAuth 2.0 authorization
|
|
pub struct AuthenticateWithOauth {
|
|
pub code: String,
|
|
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
pub oauth_provider_id: OAuthProviderId,
|
|
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
pub redirect_uri: Url,
|
|
pub show_nsfw: Option<bool>,
|
|
/// Username is mandatory at registration time
|
|
pub username: Option<String>,
|
|
/// An answer is mandatory if require application is enabled on the server
|
|
pub answer: Option<String>,
|
|
}
|