diff --git a/config/CONFIGURATION.md b/config/CONFIGURATION.md index 2c35d71..f31ee54 100644 --- a/config/CONFIGURATION.md +++ b/config/CONFIGURATION.md @@ -56,7 +56,9 @@ Configuration optionnelle pour l'authentification via un reverse proxy (Authelia |---|---|---|---|---| | `logout_url` | Oui | chaîne (URL) | — | URL de déconnexion (ex: `"https://auth.example.com/logout"`) | | `header_format` | Non | chaîne | `"Remote-User"` | Nom de l'en-tête HTTP indiquant que l'utilisateur est connecté | -| `username` | Non | chaîne | — | Nom de l'en-tête HTTP contenant le nom d'utilisateur (ex: `"Remote-User"`). Affiche le nom dans le header quand renseigné. | +| `username` | Non | chaîne | — | Nom de l'en-tête HTTP contenant le nom d'utilisateur (ex: `"Remote-Name"`). Affiche "Hi {valeur}" dans le header. | +| `header_user` | Non | chaîne | — | Nom de l'en-tête HTTP pour filtrer par utilisateur (ex: `"Remote-User"`) | +| `header_group` | Non | chaîne | — | Nom de l'en-tête HTTP pour filtrer par groupe (ex: `"Remote-Groups"`) | Quand l'en-tête défini par `header_format` est présent dans la requête, un bouton de déconnexion apparaît à droite du bouton thème. @@ -77,6 +79,8 @@ Tableau de sections. Chaque section contient : | `description` | Non | chaîne | — | Texte sous le titre | | `cardLayout` | Non | `"horizontal"` ou `"vertical"` | `"horizontal"` | Disposition des cartes dans la section | | `links` | Non | tableau | `[]` | Liste des liens | +| `visible_by_user` | Non | chaîne | — | Nom d'utilisateur requis pour voir cette section | +| `visible_by_group` | Non | chaîne | — | Groupe requis pour voir cette section | ```yaml sections: @@ -101,6 +105,8 @@ Tableau de liens. Chaque lien contient : | `iconUrl` | Non | chaîne (URL) | — | URL d'une image personnalisée (remplace `icon`) | | `color` | Non | chaîne (hex) | — | Couleur d'accent (ex: `"#2daae1"`) | | `openInNewTab` | Non | booléen | `true` | `false` pour ouvrir dans le même onglet | +| `visible_by_user` | Non | chaîne | — | Nom d'utilisateur requis pour voir ce lien | +| `visible_by_group` | Non | chaîne | — | Groupe requis pour voir ce lien | ```yaml links: diff --git a/config/dashboard.yml b/config/dashboard.yml index 028e9af..d59d0c1 100644 --- a/config/dashboard.yml +++ b/config/dashboard.yml @@ -14,12 +14,14 @@ theme: authentication: logout_url: "https://auth.socheleau.fr/logout" header_format: "Remote-User" - username: "Remote-User" + username: "Remote-Name" + header_user: "Remote-User" + header_group: "Remote-Groups" sections: - id: "global" title: "Global" - description: "Services accessibles à toute la famille" + #description: "Services accessibles à toute la famille" cardLayout: "horizontal" links: - id: "nextcloud" @@ -60,7 +62,6 @@ sections: - id: "custom" title: "Liens personnalisés" - description: "Autres liens utiles" cardLayout: "horizontal" links: - id: "homeassistant" diff --git a/src/app/page.tsx b/src/app/page.tsx index 351ccf8..50e6270 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -33,11 +33,20 @@ export default async function Home() { const isAuthenticated = config.authentication != null && headersList.has(authHeader) const username = isAuthenticated && usernameHeader ? headersList.get(usernameHeader) ?? null : null + const userHeader = config.authentication?.header_user + const groupHeader = config.authentication?.header_group + const currentUser = isAuthenticated && userHeader ? headersList.get(userHeader) ?? null : null + const userGroups = isAuthenticated && groupHeader + ? (headersList.get(groupHeader) ?? "").split(",").map((g) => g.trim()).filter(Boolean) + : [] + return ( ) } diff --git a/src/components/dashboard/Dashboard.tsx b/src/components/dashboard/Dashboard.tsx index 0acb7fe..8f7d5df 100644 --- a/src/components/dashboard/Dashboard.tsx +++ b/src/components/dashboard/Dashboard.tsx @@ -6,9 +6,11 @@ interface DashboardProps { config: DashboardConfig isAuthenticated?: boolean username?: string | null + currentUser?: string | null + userGroups?: string[] } -export function Dashboard({ config, isAuthenticated = false, username = null }: DashboardProps) { +export function Dashboard({ config, isAuthenticated = false, username = null, currentUser = null, userGroups = [] }: DashboardProps) { return (
{config.sections.map((section, index) => ( - + ))}
{config.site.showFooter !== false && ( diff --git a/src/components/dashboard/DashboardHeader.tsx b/src/components/dashboard/DashboardHeader.tsx index b357b18..0e443e9 100644 --- a/src/components/dashboard/DashboardHeader.tsx +++ b/src/components/dashboard/DashboardHeader.tsx @@ -52,7 +52,7 @@ export function DashboardHeader({ site, initialTheme, authentication, isAuthenti
{isAuthenticated && username && ( - {username} + Hi {username} )}