feat: Parse Authentik groups for project assignment
Deploy Standortplaner / deploy (push) Successful in 18s
Details
Deploy Standortplaner / deploy (push) Successful in 18s
Details
This commit is contained in:
parent
3df4a8f945
commit
773475b668
15
server.js
15
server.js
|
|
@ -65,12 +65,25 @@ function getAllowedProjects(req) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Projekte aus Header parsen (Komma-separiert)
|
// Projekte aus Attribut-Header parsen (Komma-separiert)
|
||||||
let allowedProjects = [];
|
let allowedProjects = [];
|
||||||
if (projectsHeader) {
|
if (projectsHeader) {
|
||||||
allowedProjects = projectsHeader.split(',').map(p => p.trim()).filter(Boolean);
|
allowedProjects = projectsHeader.split(',').map(p => p.trim()).filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gruppen aus Authentik-Header extrahieren und ebenfalls als Projekte behandeln
|
||||||
|
const groupsHeader = req.headers['x-authentik-groups'];
|
||||||
|
if (groupsHeader) {
|
||||||
|
const groups = groupsHeader.split('|').map(g => g.trim()).filter(Boolean);
|
||||||
|
for (const group of groups) {
|
||||||
|
// Alle Gruppen einfach als erlaubte Projekte hinzufügen.
|
||||||
|
// Was kein Projekt ist (z.B. "portal-users"), wird später beim DB-Abgleich einfach ignoriert.
|
||||||
|
if (!allowedProjects.includes(group)) {
|
||||||
|
allowedProjects.push(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
username,
|
username,
|
||||||
projects: allowedProjects,
|
projects: allowedProjects,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue