Can create accounts automatically for a given upstream provider
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -150,6 +150,10 @@ pub enum Action<'a> {
|
||||
provider: &'a Provider,
|
||||
email: &'a str,
|
||||
},
|
||||
ProviderAccountAutoCreated {
|
||||
provider: &'a Provider,
|
||||
user: LoggableUser,
|
||||
},
|
||||
ProviderAccountDisabled {
|
||||
provider: &'a Provider,
|
||||
email: &'a str,
|
||||
@@ -282,6 +286,11 @@ impl Action<'_> {
|
||||
"could not login using provider {} because the email {email} could not be associated to any account!",
|
||||
&provider.id.0
|
||||
),
|
||||
Action::ProviderAccountAutoCreated { provider, user } => format!(
|
||||
"triggered automatic account creation for {} from provider {} because it was not found in local accounts list!",
|
||||
user.quick_identity(),
|
||||
&provider.id.0
|
||||
),
|
||||
Action::ProviderAccountDisabled { provider, email } => format!(
|
||||
"could not login using provider {} because the account associated to the email {email} is disabled!",
|
||||
&provider.id.0
|
||||
|
||||
@@ -26,6 +26,10 @@ pub struct Provider {
|
||||
///
|
||||
/// (.well-known/openid-configuration endpoint)
|
||||
pub configuration_url: String,
|
||||
|
||||
/// Set to true if accounts on BasicOIDC should be automatically created from this provider
|
||||
#[serde(default)]
|
||||
pub allow_auto_account_creation: bool,
|
||||
}
|
||||
|
||||
impl Provider {
|
||||
|
||||
@@ -14,6 +14,12 @@ use crate::utils::time::{fmt_time, time};
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, Encode, Decode)]
|
||||
pub struct UserID(pub String);
|
||||
|
||||
impl UserID {
|
||||
pub fn random() -> Self {
|
||||
Self(uuid::Uuid::new_v4().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct GeneralSettings {
|
||||
pub uid: UserID,
|
||||
@@ -46,6 +52,12 @@ impl GrantedClients {
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct FactorID(pub String);
|
||||
|
||||
impl FactorID {
|
||||
pub fn random() -> Self {
|
||||
Self(uuid::Uuid::new_v4().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub enum TwoFactorType {
|
||||
TOTP(TotpKey),
|
||||
@@ -295,7 +307,7 @@ impl Eq for User {}
|
||||
impl Default for User {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
uid: UserID(uuid::Uuid::new_v4().to_string()),
|
||||
uid: UserID::random(),
|
||||
first_name: "".to_string(),
|
||||
last_name: "".to_string(),
|
||||
username: "".to_string(),
|
||||
|
||||
@@ -71,7 +71,7 @@ impl UsersSyncBackend for EntityManager<User> {
|
||||
|
||||
fn create_user_account(&mut self, settings: GeneralSettings) -> Res<UserID> {
|
||||
let mut user = User {
|
||||
uid: UserID(uuid::Uuid::new_v4().to_string()),
|
||||
uid: UserID::random(),
|
||||
..Default::default()
|
||||
};
|
||||
user.update_general_settings(settings);
|
||||
|
||||
Reference in New Issue
Block a user