diff --git a/.theia/launch.json b/.theia/launch.json new file mode 100644 index 0000000..9a49ac9 --- /dev/null +++ b/.theia/launch.json @@ -0,0 +1,8 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + "version": "0.2.0", + "configurations": [ + + ] +} diff --git a/public/auth.js b/public/auth.js new file mode 100644 index 0000000..beaffca --- /dev/null +++ b/public/auth.js @@ -0,0 +1,44 @@ +// auth.js - Gestion de la connexion SSO +const authConfig = { + authority: "https://idp.a5l.fr/realms/A5L", + client_id: "soundboard_a5l", // À enregistrer sur votre IdP + redirect_uri: window.location.origin + "/callback.html", + response_type: "code", + scope: "openid profile email" +}; + +function login() { + // Construction de l'URL exacte attendue par Keycloak + const authUrl = `${authConfig.authority}/protocol/openid-connect/auth?` + + `client_id=${authConfig.client_id}&` + + `redirect_uri=${encodeURIComponent(authConfig.redirect_uri)}&` + + `response_type=${authConfig.response_type}&` + + `scope=${authConfig.scope}&` + + `state=${generateState()}`; // Sécurité recommandée + + window.location.href = authUrl; +} + +// Fonction utilitaire pour le paramètre 'state' (protection CSRF) +function generateState() { + const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + let result = ''; + for (let i = 0; i < 16; i++) { + result += charset.charAt(Math.floor(Math.random() * charset.length)); + } + return result; +} + +function logout() { + localStorage.removeItem('auth_token'); + window.location.reload(); +} + +function checkAuth() { + const token = localStorage.getItem('auth_token'); + if (!token) { + document.body.classList.add('not-logged-in'); + return false; + } + return true; +} \ No newline at end of file diff --git a/public/callback.html b/public/callback.html new file mode 100644 index 0000000..c016916 --- /dev/null +++ b/public/callback.html @@ -0,0 +1,20 @@ + + + + + + \ No newline at end of file diff --git a/public/index.html b/public/index.html index ca2b0eb..bd22e9b 100644 --- a/public/index.html +++ b/public/index.html @@ -4,6 +4,7 @@ Soundboard A5L + @@ -16,9 +17,18 @@
- v1.213 + 1.214 + +
+ + +
+
diff --git a/public/readme.md b/public/readme.md index ebbed1d..14ad62e 100644 --- a/public/readme.md +++ b/public/readme.md @@ -10,9 +10,11 @@ * Arrêt de toutes les pistes avec un bouton STOP ALL * Progressif Web App : fonctionnement offline * Utilisation d'IndexedDB pour stocker les son +* Empecher le device de se mettre en veille ## Fonctionnalités à venir +* Suppression d'une association * Authentification pour stocker les sons sur le serveur * Authentification pour récuperer les sons depuis le serveur * Partager des sons pour que d'autres puissent les déployer dans leur soundboard diff --git a/public/script.js b/public/script.js index 9d2fb36..b45a80d 100644 --- a/public/script.js +++ b/public/script.js @@ -43,6 +43,16 @@ async function getSound(id) { // Lancement automatique au démarrage // On attend que la page soit prête window.addEventListener('load', () => { + if (checkAuth()) { + document.getElementById('loginBtn').style.display = 'none'; + document.getElementById('userProfile').style.display = 'flex'; + // Charger les données utilisateur depuis le serveur ici si besoin + init(); + } else { + // Optionnel : afficher une grille vide ou un message + console.log("Utilisateur non connecté."); + } + migrateToIndexedDB(); });