-
-
Notifications
You must be signed in to change notification settings - Fork 884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSO Support #4881
SSO Support #4881
Changes from all commits
e0b20cd
6b2ee3d
347815f
5cf4839
6c6015e
0d151a9
f23eafc
d97d27a
337598f
4d09b74
331eff9
438516d
a5a3ec9
2d6ee77
8edfe1d
cd2d6c6
d5dbe3f
454402b
8e3038d
7698794
cfa0174
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,69 @@ | ||||
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, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whats this for, is it required for oauth? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is used in the oauth token issuance API call: lemmy/crates/api_crud/src/user/create.rs Line 277 in a88d3af
|
||||
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>, | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be false right? If there's no password encrypted, that means its an oauth-type account, and you shouldn't be able to change the password.
I think you could use map then:
let valid: bool = password_encrypted.map(|password_encrypted| verify...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every OIDC account is linked to a local_user. If you sign up with OIDC with a new email a local_user gets created. You can set a password to an account created using OIDC and start using the email and password to login if you want.
This is needed when you want to delete your account because a password is required for account deletion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds confusing. Wouldnt it be better to allow account deletion directly with oauth?
Though it makes sense that users can switch from oauth to password login and vice versa.