7 Commits

Author SHA1 Message Date
43c0b9ffc1 Merge pull request 'nx-auth' (#905) from nx-auth into staging
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m50s
CI/CD Pipeline / deploy-staging (push) Successful in 7m30s
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #905
2025-04-16 10:19:13 +02:00
588520914c add nextcloud auth route
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2025-04-16 10:18:27 +02:00
819c4bb31b Merge pull request 'fix tests' (#903) from fix-cal-uid into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m16s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m9s
Reviewed-on: #903
2025-04-15 23:18:32 +02:00
9a30ce0afb Merge pull request 'make default duration 3 hrs (to have a larger block in the cal)' (#901) from fix-cal-uid into main
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
Reviewed-on: #901
2025-04-15 23:13:19 +02:00
29f2cadb99 Merge pull request 'fix ci' (#899) from fix-cal-uid into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 13m48s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 7m0s
Reviewed-on: #899
2025-04-15 22:12:32 +02:00
dfb53291b7 Merge pull request 'have unique uid's, fixes error in some clients (e.g. sogo)' (#896) from fix-cal-uid into main
Some checks failed
CI/CD Pipeline / test (push) Failing after 12m43s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #896
2025-04-15 20:56:00 +02:00
418bcc3143 Merge pull request 'update deps' (#893) from upd into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 13m42s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 27m38s
Reviewed-on: #893
2025-04-15 14:20:28 +02:00

View File

@@ -7,7 +7,7 @@ use rocket::{
form::Form, form::Form,
fs::FileServer, fs::FileServer,
get, get,
http::Cookie, http::{Cookie, Status},
post, post,
request::FlashMessage, request::FlashMessage,
response::{Flash, Redirect}, response::{Flash, Redirect},
@@ -123,11 +123,23 @@ async fn wikiauth(db: &State<SqlitePool>, login: Form<LoginForm<'_>>) -> String
"FAIL".into() "FAIL".into()
} }
#[get("/?<username>&<password>")]
async fn nextcloud_auth(db: &State<SqlitePool>, username: String, password: String) -> Status {
if let Ok(user) = User::login(db, &username, &password).await {
if user.has_role(db, "admin").await {
return Status::Ok;
}
if user.has_role(db, "Vorstand").await {
return Status::Ok;
}
}
Status::Unauthorized
}
#[catch(401)] //Unauthorized #[catch(401)] //Unauthorized
fn unauthorized_error(req: &Request) -> Redirect { fn unauthorized_error(req: &Request) -> Redirect {
// Save the URL the user tried to access, to be able to go there once logged in // Save the URL the user tried to access, to be able to go there once logged in
let mut redirect_cookie = Cookie::new("redirect_url", format!("{}", req.uri())); let mut redirect_cookie = Cookie::new("redirect_url", format!("{}", req.uri()));
println!("{}", req.uri());
redirect_cookie.set_expires(OffsetDateTime::now_utc() + Duration::hours(1)); redirect_cookie.set_expires(OffsetDateTime::now_utc() + Duration::hours(1));
req.cookies().add_private(redirect_cookie); req.cookies().add_private(redirect_cookie);
@@ -265,6 +277,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
.mount("/", routes![index, steering, impressum]) .mount("/", routes![index, steering, impressum])
.mount("/auth", auth::routes()) .mount("/auth", auth::routes())
.mount("/wikiauth", routes![wikiauth]) .mount("/wikiauth", routes![wikiauth])
.mount("/nxauth", routes![nextcloud_auth])
.mount("/new-blogpost", routes![new_blogpost]) .mount("/new-blogpost", routes![new_blogpost])
.mount("/blogpost-unpublished", routes![blogpost_unpublished]) .mount("/blogpost-unpublished", routes![blogpost_unpublished])
.mount("/log", log::routes()) .mount("/log", log::routes())