New users dont get teh `skynet-users` group #55
Labels
No labels
Trainee - Good First Issue
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Skynet/ldap_backend#55
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Currently we have an issue where folks who create a skynet account dont get access to our services until after the
update_groupsscript has been run.We know from
get_wolves_mailthat the folks who get to that stage either are or have been members of computer society.for record in get_wolves_mail(db, &user_db.mail).await {In
authentik_create_accountis where the account is actually created onauthentikauthentik_create_account(config, &user, &record, &pass).await;groupsare set inauthentik_create_account(Struct definition here: https://docs.rs/authentik-client/2026.5.3/authentik_client/models/user_request/struct.UserRequest.html )groups: Some(vec![]),From the
update_groupsscript we are able to see where to find the group id&config.authentik.groups.userupdate_group(config, &config.authentik.groups.user, users).await?;To do
Adding user role to folks
Add
&config.authentik.groups.usertogroups: Some(vec![]),Limit signups to current/active members only
Currently the command to check teh wolves email only checks if that email is used for any past/current members;
pub async fn get_wolves_mail(db: &Pool<Sqlite>, mail: &str) -> Vec<AccountWolves> {sqlx::query_as::<_, AccountWolves>(r#"SELECT *FROM accounts_wolvesWHERE email = ?"#,).bind(mail).fetch_all(db).await.unwrap_or(vec![])}One way to tackle this would eb to use something like
update_groupswhere it checks tehexpiryfield is greater than now.for record in get_wolves(db).await {// only import users if it is actually active.if record.expiry < get_now_iso(true) {continue;}This would be easy to integrate after teh current check for if the person has a
*@skynet.ieemail listed on wolves.// skynet emails not permittedif record.email.trim().ends_with("@skynet.ie") {continue;}This might also need to be added up in the initial request where the user starts teh process
// skynet emails not permittedif record.email.trim().ends_with("@skynet.ie") {continue;}// if using csv check if the account is within dateProvide feedback to the user
One slight issue now is that if a user does have any errors which prevent account creation in here then they arent informed:
for record in get_wolves_mail(db, &user_db.mail).await {// skynet emails not permittedif record.email.trim().ends_with("@skynet.ie") {continue;}authentik_create_account(config, &user, &record, &pass).await;}It might be worth having a flag before that for loop which checks if teh account was created, and if not it returns an error instead of teh
Ok(json!({"result": "success"}).into())