diff --git a/README.md b/README.md index e86da91..25234d6 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,301 @@ -# Projet gesthub +# 📘 Gesthub +last-commit -## Membres +Construit avec les outils et les technologies nécessaires : -- Lajus Erika -- Lemoule Duparc Nathan -- LABAT Nino - -## Présentation du projet -Ce projet vise à créer une interface fait pour faciliter la gestion et communication au sein d'un projet ou d'une entreprise. - -On y retrouve deux roles distints : - -**1. Admin :** -Gestion des utilisateurs : Création et suppression de comptes par les admins. - - Authentification sécurisée:Avec nom, prénom et mot de passe. - - Gestion des annonces : Les admins peuvent publier des annonces sous forme de post-it qui apparait dans une zone défini sur l'interface des membres. -Chaque annonce a une date limite et disparaît automatiquement une fois la date dépassée. - - Gestion agenda : ajoute les évènement globaux - - Gestionnaire des taches : Création de tableaux, listes et cartes pour l'organisation des tâches. - -**2. Membre :** - Agenda/Planning partagé : -Visibilité des événements globaux ajouté par les admins. -Possibilité d'ajouter des événements personnels. - - Gestion de projets façon Trello : -Possibilité d'ajouter des cartes -Suivi de l'avancement des projets. -Visibilité sur les différents tableaux. - -Messagerie interne : -Système de chat pour la communication en temps réel entre membres. - -Liens vers outils externes : -Boutons pour accéder rapidement à des outils comme Discord, etc. +Flask +JSON +Keycloak +GNU%20Bash +MariaDB +
+Docker +Python +Mattermost +## 🧱 Objectif + +Créer un site web multi-services (extranet/intranet) avec : +- Authentification centralisée via **Keycloak** +- Reverse proxy **Caddy** +- Frontend/backend **Flask** +- Chat & Gestion de tâches via **Mattermost** +- Gestion d’annonces via JSON avec droits `/admin` (a faire) + +--- + +## 🐳 Démarrage du projet + +### 1. **Structure Docker** + +Les services sont définis dans `docker-compose.yml` : +- `caddy`: Reverse proxy + HTTPS automatique +- `flask`: Application web backend +- `mariadb`: Base de données +- `keycloak`: SSO + gestion utilisateurs +- `mattermost`: Chat et gestion de tâches (type Trello) + +Réseau utilisé : `gesthub_gesthub` + +--- + +## 🔐 Authentification Keycloak + +### ✅ Étapes : + +1. Création du **realm `Gesthub`** +2. Ajout des clients (Flask et Mattermost) +3. Activation `OpenID Connect` +4. Configuration des **Redirect URIs** + - Exemples : + - Flask → `https://dashboard.ninolbt.com/login/callback` + - Mattermost → `https://mattermost.ninolbt.com/signup/openid/complete` + +5. Pour les utilisateurs `/admin`, on utilise le **groupe `/admin`** dans Keycloak. + +--- + +## 🌐 Reverse Proxy Caddy + +### 🛠️ `Caddyfile` : + +```caddyfile +https://dashboard.ninolbt.com { + reverse_proxy flask:5000 +} + +https://keycloak.ninolbt.com { + reverse_proxy keycloak:8080 +} + +https://mattermost.ninolbt.com { + reverse_proxy mattermost:8065 +} +``` + +**Volumes persistants** : +`caddy_data` et `caddy_config` montés dans `/data` et `/config` + +--- + +## 🧩 Flask +- back du dashboard +- Permet la création/modification/suppression d’annonces en JSON (en test) +- Accessible uniquement pour les utilisateurs avec le rôle `/admin` (via token) (en test) +- Chargement des assets statiques corrigé avec Caddy + +--- + +## 🗂️ Gestion des droits + +- Auth via Keycloak pour Flask, Mattermost, Wekan +- Vérification des groupes dans Flask (`/admin`) +- Redirections correctes avec URLs HTTPS Caddy + +--- + +## 📌 Bugs et corrections + +- ⚠️ Redirection Keycloak incorrecte → Corrigé avec bon `redirect_uri` +- ⚠️ Assets statiques Flask → corrigé via URL absolue en HTTPS +- ✅ Reverse proxy fonctionne avec tous les services +- ✅ HTTPS opérationnel via Caddy avec certificats Let's Encrypt + +--- + +## 🚀 Démarrage + +```bash +docker compose up --build -d +``` + +Si besoin : +```bash +docker compose logs -f [service] +``` + +--- + +## 📤 Export complet + +Pour rendre le projet exportable : +- Tout est containerisé (Docker) +- Config Keycloak exporté (JSON disponible dans le dossier `export_keycloak`) +- `docker-compose.yml`, `Caddyfile`, fichier disponible dans le repo + +repo-top-language +repo-language-count + +Built with the tools and technologies: + +Flask +JSON +Keycloak +GNU%20Bash +MariaDB +
+Docker +Python +Mattermost +bat + + +
+ +--- + +## Table of Contents + +- [Overview](#overview) +- [Getting Started](#getting-started) + - [Prerequisites](#prerequisites) + - [Installation](#installation) + - [Usage](#usage) + - [Testing](#testing) +- [Contributing](#contributing) +- [Acknowledgment](#acknowledgment) + +--- + +## Overview + +Gesthub is a powerful developer tool designed to streamline the setup and management of full-stack applications by integrating essential services into a cohesive environment. + +**Why Gesthub?** + +This project simplifies the development process, allowing developers to focus on building features rather than managing infrastructure. The core features include: + +- 🚀 **Docker Compose Configuration:** Simplifies orchestration of multiple services, reducing setup complexity. +- 🌐 **Local Domain Management:** Scripts to add local domain entries streamline access to services, enhancing the development experience. +- 🔒 **Integrated User Authentication:** Utilizes Keycloak for secure user management, addressing security concerns. +- ⚙️ **Seamless Routing and Load Balancing:** Caddyfile configuration ensures efficient request handling, improving performance. +- 🎨 **User-Friendly Interface:** Responsive design enhances collaboration and user experience. +- 📊 **Centralized Data Management:** Structured storage for advertisements improves data handling capabilities. + +--- + +## Getting Started + +### Prerequisites + +This project requires the following dependencies: + +- **Programming Language:** Shell +- **Package Manager:** Bash +- **Container Runtime:** Docker + +### Installation + +Build gesthub from the source and intsall dependencies: + +1. **Clone the repository:** + + ```sh + ❯ git clone https://github.com/M1n-0/gesthub + ``` + +2. **Navigate to the project directory:** + + ```sh + ❯ cd gesthub + ``` + +3. **Install the dependencies:** + +**Using [docker](https://www.docker.com/):** + +```sh +❯ docker build -t M1n-0/gesthub . +``` +**Using [bash](https://www.gnu.org/software/bash/):** + +```sh +❯ chmod +x {entrypoint} +``` + +### Usage + +Run the project with: + +**Using [docker](https://www.docker.com/):** + +```sh +docker run -it {image_name} +``` +**Using [bash](https://www.gnu.org/software/bash/):** + +```sh +./{entrypoint} +``` + +### Testing + +Gesthub uses the {__test_framework__} test framework. Run the test suite with: + +**Using [docker](https://www.docker.com/):** + +```sh +echo 'INSERT-TEST-COMMAND-HERE' +``` +**Using [bash](https://www.gnu.org/software/bash/):** + +```sh +bats *.bats +``` + +--- + +## Contributing + +- **💬 [Join the Discussions](https://github.com/M1n-0/gesthub/discussions)**: Share your insights, provide feedback, or ask questions. +- **🐛 [Report Issues](https://github.com/M1n-0/gesthub/issues)**: Submit bugs found or log feature requests for the `gesthub` project. +- **💡 [Submit Pull Requests](https://github.com/M1n-0/gesthub/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs. + +
+Contributing Guidelines + +1. **Fork the Repository**: Start by forking the project repository to your github account. +2. **Clone Locally**: Clone the forked repository to your local machine using a git client. + ```sh + git clone https://github.com/M1n-0/gesthub + ``` +3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name. + ```sh + git checkout -b new-feature-x + ``` +4. **Make Your Changes**: Develop and test your changes locally. +5. **Commit Your Changes**: Commit with a clear message describing your updates. + ```sh + git commit -m 'Implemented new feature x.' + ``` +6. **Push to github**: Push the changes to your forked repository. + ```sh + git push origin new-feature-x + ``` +7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations. +8. **Review**: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution! +
+ +
+Contributor Graph +
+

+ + + +

+
+ +--- + +## Acknowledgments + +- Credit `contributors`, `inspiration`, `references`, etc. + +
⬆ Return
+ +--- diff --git a/add-localhosts.bat b/add-localhosts.bat deleted file mode 100644 index 46a11ff..0000000 --- a/add-localhosts.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off -set HOSTS_FILE=%SystemRoot%\System32\drivers\etc\hosts - -set DOMAINS=flask.gesthub keycloak.gesthub chat.gesthub wekan.gesthub - -echo [🔧] Mise à jour de %HOSTS_FILE% - -for %%D in (%DOMAINS%) do ( - findstr /C:"%%D" %HOSTS_FILE% >nul - if errorlevel 1 ( - echo 127.0.0.1 %%D >> %HOSTS_FILE% - echo [+] Ajouté : %%D - ) else ( - echo [=] Déjà présent : %%D - ) -) - -echo [✅] Terminé. -pause diff --git a/add-localhosts.sh b/add-localhosts.sh deleted file mode 100755 index edb59bb..0000000 --- a/add-localhosts.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -HOSTS_FILE="/etc/hosts" -DOMAINS=("flask.gesthub" "keycloak.gesthub" "chat.gesthub" "wekan.gesthub") - -echo "[🔧] Mise à jour de : $HOSTS_FILE" - -for domain in "${DOMAINS[@]}"; do - if grep -q "$domain" "$HOSTS_FILE"; then - echo "[=] Déjà présent : $domain" - else - echo "127.0.0.1 $domain" | sudo tee -a "$HOSTS_FILE" > /dev/null - echo "[+] Ajouté : $domain" - fi -done - -echo "[✅] Terminé." diff --git a/export_keycloak/flask-app.json b/export_keycloak/flask-app.json new file mode 100644 index 0000000..54fe8d4 --- /dev/null +++ b/export_keycloak/flask-app.json @@ -0,0 +1,59 @@ +{ + "clientId": "flask-app", + "name": "dashboard", + "description": "", + "rootUrl": "https://dashboard.ninolbt.com", + "adminUrl": "https://dashboard.ninolbt.com", + "baseUrl": "https://dashboard.ninolbt.com", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "secret": "T5G5jzCBiphnBNh9uuj0f6YNc9HrP8r4", + "redirectUris": [ + "https://dashboard.ninolbt.com/*" + ], + "webOrigins": [ + "https://dashboard.ninolbt.com" + ], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": true, + "serviceAccountsEnabled": false, + "publicClient": false, + "frontchannelLogout": true, + "protocol": "openid-connect", + "attributes": { + "oidc.ciba.grant.enabled": "false", + "client.secret.creation.time": "1747419098", + "backchannel.logout.session.required": "true", + "post.logout.redirect.uris": "https://dashboard.ninolbt.com/*", + "display.on.consent.screen": "false", + "oauth2.device.authorization.grant.enabled": "false", + "backchannel.logout.revoke.offline.tokens": "false" + }, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": true, + "nodeReRegistrationTimeout": -1, + "defaultClientScopes": [ + "web-origins", + "acr", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ], + "access": { + "view": true, + "configure": true, + "manage": true + } +} \ No newline at end of file diff --git a/export_keycloak/mattermost.json b/export_keycloak/mattermost.json new file mode 100644 index 0000000..42af1a8 --- /dev/null +++ b/export_keycloak/mattermost.json @@ -0,0 +1,58 @@ +{ + "clientId": "mattermost", + "name": "mattermost", + "description": "", + "rootUrl": "https://mattermost.ninolbt.com", + "adminUrl": "https://mattermost.ninolbt.com", + "baseUrl": "https://mattermost.ninolbt.com", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "secret": "DwImxpeoe70Ulu6uslL2I8B0IQr4FmKz", + "redirectUris": [ + "https://mattermost.ninolbt.com/signup/openid/complete" + ], + "webOrigins": [ + "https://mattermost.ninolbt.com" + ], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": true, + "serviceAccountsEnabled": false, + "publicClient": false, + "frontchannelLogout": true, + "protocol": "openid-connect", + "attributes": { + "oidc.ciba.grant.enabled": "false", + "client.secret.creation.time": "1747504584", + "backchannel.logout.session.required": "true", + "display.on.consent.screen": "false", + "oauth2.device.authorization.grant.enabled": "false", + "backchannel.logout.revoke.offline.tokens": "false" + }, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": true, + "nodeReRegistrationTimeout": -1, + "defaultClientScopes": [ + "web-origins", + "acr", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ], + "access": { + "view": true, + "configure": true, + "manage": true + } +} \ No newline at end of file diff --git a/start-gesthub.sh b/start-gesthub.sh deleted file mode 100644 index ad28472..0000000 --- a/start-gesthub.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -PROJECT_DOMAIN="gesthub" -HOSTS_LINE="127.0.0.1 flask.$PROJECT_DOMAIN wekan.$PROJECT_DOMAIN chat.$PROJECT_DOMAIN" - -echo "🔧 Vérification des droits (sudo peut être requis pour modifier /etc/hosts)..." - -# Ajout dans /etc/hosts si absent -if ! grep -q "$PROJECT_DOMAIN" /etc/hosts; then - echo "✅ Ajout de $PROJECT_DOMAIN dans /etc/hosts..." - echo "$HOSTS_LINE" | sudo tee -a /etc/hosts > /dev/null -else - echo "✔️ Domaine $PROJECT_DOMAIN déjà présent dans /etc/hosts." -fi - -echo "🚀 Lancement des services Docker..." -docker compose up --build diff --git a/start-infra.sh b/start-infra.sh deleted file mode 100644 index ad28472..0000000 --- a/start-infra.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -PROJECT_DOMAIN="gesthub" -HOSTS_LINE="127.0.0.1 flask.$PROJECT_DOMAIN wekan.$PROJECT_DOMAIN chat.$PROJECT_DOMAIN" - -echo "🔧 Vérification des droits (sudo peut être requis pour modifier /etc/hosts)..." - -# Ajout dans /etc/hosts si absent -if ! grep -q "$PROJECT_DOMAIN" /etc/hosts; then - echo "✅ Ajout de $PROJECT_DOMAIN dans /etc/hosts..." - echo "$HOSTS_LINE" | sudo tee -a /etc/hosts > /dev/null -else - echo "✔️ Domaine $PROJECT_DOMAIN déjà présent dans /etc/hosts." -fi - -echo "🚀 Lancement des services Docker..." -docker compose up --build diff --git a/web/templates/view/index.html b/web/templates/view/index.html index 6c05553..0897289 100644 --- a/web/templates/view/index.html +++ b/web/templates/view/index.html @@ -41,7 +41,7 @@
- {{ user['preferred_username'] }} + {{ user['preferred_username'] }}

Mon profil

Déconnexion