Compare commits

..

2 commits

Author SHA1 Message Date
29d1f41de5 Adding primevue to project 2025-04-04 11:21:19 +02:00
89e7f84469 Adding PrimeVue dependencies 2025-04-04 11:20:46 +02:00
15 changed files with 44 additions and 46 deletions

View file

@ -1,4 +1,4 @@
{ {
"rust-analyzer.check.features": "all", "rust-analyzer.check.features": "all",
"rust-analyzer.cargo.features": "all" "rust-analyzer.cargo.features": "all"
} }

View file

@ -1,8 +1,15 @@
when: when:
- event: pull_request - event: push
branch: main
steps: steps:
- name: "Run nix flake check" - name: "Run nix flake check"
image: docker.nix-community.org/nixpkgs/nix-flakes image: docker.nix-community.org/nixpkgs/nix-flakes
commands: commands:
- nix fmt -- --fail-on-change - nix fmt
- name: push commit
image: appleboy/drone-git-push
settings:
remote_name: origin
branch: main
local_ref: main

View file

@ -1,3 +1,2 @@
# peer-group-grading # peer-group-grading
Wir sind cool
Wir sind cool

View file

@ -2,5 +2,8 @@
"version": "1", "version": "1",
"name": "pgg-bruno", "name": "pgg-bruno",
"type": "collection", "type": "collection",
"ignore": ["node_modules", ".git"] "ignore": [
} "node_modules",
".git"
]
}

View file

@ -1,12 +1,11 @@
use actix_session::Session; use actix_session::Session;
use actix_web::{ use actix_web::{
post, HttpResponse, Responder, post,
web::{self, ServiceConfig}, web::{self, ServiceConfig},
HttpResponse, Responder,
}; };
use serde::Deserialize; use serde::Deserialize;
use crate::{error::ApiError, Database}; use crate::{Database, error::ApiError};
#[derive(Deserialize)] #[derive(Deserialize)]
struct LoginRequest { struct LoginRequest {

View file

@ -1,4 +1,4 @@
use actix_web::{delete, get, post, put, Responder}; use actix_web::{Responder, delete, get, post, put};
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) { pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(get_classes) cfg.service(get_classes)

View file

@ -1,4 +1,4 @@
use actix_web::{delete, get, post, put, Responder}; use actix_web::{Responder, delete, get, post, put};
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) { pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(get_groups) cfg.service(get_groups)

View file

@ -1,9 +1,9 @@
use actix_web::{delete, get, post, put, web, Result}; use actix_web::{Result, delete, get, post, put, web};
use uuid::Uuid; use uuid::Uuid;
use validator::Validate; use validator::Validate;
use crate::db::project::CreateProject;
use crate::db::Database; use crate::db::Database;
use crate::db::project::CreateProject;
use crate::entity; use crate::entity;
use crate::error::ApiError; use crate::error::ApiError;

View file

@ -1,4 +1,4 @@
use actix_web::{delete, get, post, put, Responder}; use actix_web::{Responder, delete, get, post, put};
pub fn setup(cfg: &mut actix_web::web::ServiceConfig) { pub fn setup(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(get_templates) cfg.service(get_templates)

View file

@ -1,5 +1,5 @@
use crate::{entity, error::ApiError, Database}; use crate::{Database, entity, error::ApiError};
use actix_web::{delete, get, post, put, web, Responder}; use actix_web::{Responder, delete, get, post, put, web};
use serde::Deserialize; use serde::Deserialize;
use validator::Validate; use validator::Validate;

View file

@ -1,7 +1,7 @@
use crate::error::ApiError; use crate::error::ApiError;
use argon2::{ use argon2::{
password_hash::{rand_core::OsRng, PasswordHasher, SaltString},
Argon2, PasswordHash, PasswordVerifier, Argon2, PasswordHash, PasswordVerifier,
password_hash::{PasswordHasher, SaltString, rand_core::OsRng},
}; };
use sea_orm::{ use sea_orm::{
ActiveModelTrait, ActiveModelTrait,
@ -10,7 +10,7 @@ use sea_orm::{
}; };
use uuid::Uuid; use uuid::Uuid;
use crate::{entity, Database}; use crate::{Database, entity};
impl Database { impl Database {
pub async fn create_user( pub async fn create_user(

View file

@ -1,4 +1,4 @@
use actix_web::{cookie::time::error, http::StatusCode, HttpResponse, ResponseError}; use actix_web::{HttpResponse, ResponseError, cookie::time::error, http::StatusCode};
use sea_orm::TransactionError; use sea_orm::TransactionError;
use thiserror::Error; use thiserror::Error;

View file

@ -1,14 +1,14 @@
use actix_files::NamedFile; use actix_files::NamedFile;
use actix_session::{storage::RedisSessionStore, SessionMiddleware}; use actix_session::{SessionMiddleware, storage::RedisSessionStore};
use actix_web::{cookie::Key, middleware::Logger, web, App, HttpResponse, HttpServer}; use actix_web::{App, HttpResponse, HttpServer, cookie::Key, middleware::Logger, web};
use log::debug; use log::debug;
mod controller; mod controller;
mod db; mod db;
mod error; mod error;
pub use db::entity;
pub use db::Database; pub use db::Database;
pub use db::entity;
#[derive(Clone)] #[derive(Clone)]
struct AppConfig { struct AppConfig {

View file

@ -30,19 +30,17 @@ fn authenticate_user(username: &str, password: &str) -> Result<bool, Box<dyn std
let ldap = LdapConn::new(&ldap_server)?; let ldap = LdapConn::new(&ldap_server)?;
// Search for the user in the LDAP directory // Search for the user in the LDAP directory
let (rs, _res) = ldap let (rs, _res) = ldap.search(
.search( &format!("ou=users,{}", base_dn), // Search under "ou=users"
&format!("ou=users,{}", base_dn), // Search under "ou=users" Scope::Subtree, // Search all levels
Scope::Subtree, // Search all levels &format!("(uid={})", username), // Filter by username
&format!("(uid={})", username), // Filter by username vec!["dn"], // Retrieve the distinguished name (DN)
vec!["dn"], // Retrieve the distinguished name (DN) )?.success()?;
)?
.success()?;
// If user is found, attempt to authenticate with their DN and password // If user is found, attempt to authenticate with their DN and password
if let Some(entry) = rs.into_iter().next() { if let Some(entry) = rs.into_iter().next() {
let user_dn = SearchEntry::construct(entry).dn; // Extract user DN let user_dn = SearchEntry::construct(entry).dn; // Extract user DN
// Reconnect and bind with user credentials // Reconnect and bind with user credentials
let user_ldap = LdapConn::new(&ldap_server)?; let user_ldap = LdapConn::new(&ldap_server)?;
let auth_result = user_ldap.simple_bind(&user_dn, password)?.success(); let auth_result = user_ldap.simple_bind(&user_dn, password)?.success();
@ -62,4 +60,4 @@ async fn main() -> std::io::Result<()> {
.bind(("127.0.0.1", 8080))? .bind(("127.0.0.1", 8080))?
.run() .run()
.await .await
} }

View file

@ -39,21 +39,13 @@ services:
- ./crates/ldap/src/users.ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom/users.ldif - ./crates/ldap/src/users.ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom/users.ldif
healthcheck: healthcheck:
test: test: ["CMD", "ldapsearch", "-x", "-H", "ldap://localhost", "-b", "dc=Schule,dc=intern"]
[
"CMD",
"ldapsearch",
"-x",
"-H",
"ldap://localhost",
"-b",
"dc=Schule,dc=intern",
]
interval: 30s interval: 30s
retries: 3 retries: 3
volumes: volumes:
postgres_data: postgres_data:
redis: redis:
openldap_data: openldap_data:
openldap_config: openldap_config: