diff options
| author | Simon Rettberg | 2025-09-25 15:20:34 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2025-09-25 15:20:34 +0200 |
| commit | cc74ae97b9f91b38fecb1c24600c3eb7e4717b4d (patch) | |
| tree | 0d752c886ba2f0b159ca2b860e0de452ba254057 /src/global.cpp | |
| parent | Fix IdP list merging (diff) | |
| download | slxgreeter-cc74ae97b9f91b38fecb1c24600c3eb7e4717b4d.tar.gz slxgreeter-cc74ae97b9f91b38fecb1c24600c3eb7e4717b4d.tar.xz slxgreeter-cc74ae97b9f91b38fecb1c24600c3eb7e4717b4d.zip | |
Diffstat (limited to 'src/global.cpp')
| -rw-r--r-- | src/global.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/global.cpp b/src/global.cpp index 8f19899..468a6f2 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -142,11 +142,12 @@ bool Global::isValidShibCreds(const QString &ustr, const QString &upass) && R_PASS.match(upass).hasMatch(); } -const QVariantMap& Global::getCombinedIdpWhitelist() +const QMap<QString, QSet<QString>> &Global::getCombinedIdpWhitelist() { - static QVariantMap m_combinedWhitelist; + static QMap<QString, QSet<QString>> m_combinedWhitelist; if (!m_combinedWhitelist.isEmpty()) return m_combinedWhitelist; + static QRegularExpression R_CLEANUP("[^\\w. /:@-]", QRegularExpression::UseUnicodePropertiesOption); static QRegularExpression R_ENTITLEMENT("entitlement=(\\S+)"); QDir configDir(QLatin1String("/opt/openslx/pam/shibboleth/whitelist")); QFileInfoList fileInfoList = configDir.entryInfoList(QStringList() << "*.idp", QDir::Files); @@ -161,7 +162,9 @@ const QVariantMap& Global::getCombinedIdpWhitelist() QSet<QString> list; QTextStream in(&f); while (!in.atEnd()) { - auto line = in.readLine(); + auto line = in.readLine().replace(R_CLEANUP, QString()); + if (line.isEmpty()) + continue; if (line.startsWith('#')) { // Comment/metadata auto m = R_ENTITLEMENT.match(line); @@ -184,22 +187,6 @@ const QVariantMap& Global::getCombinedIdpWhitelist() tmpMap.insert(filter, list); } } - // Now stringify all the lists, so we can put it into a variant map (which we can turn into JSON) - QVariantMap retval; - for (auto it = tmpMap.constBegin(); it != tmpMap.constEnd(); ++it) { - const auto &filter = it.key(); - const auto &list = it.value(); - QString combined; - for (const QString &s : list) { - if (!combined.isEmpty()) { - combined.append(QLatin1Char(' ')); - } - combined += s; - } - retval.insert(filter, combined.replace( - QRegularExpression("[^\\w. /:@-]", QRegularExpression::UseUnicodePropertiesOption), - QString())); - } - m_combinedWhitelist = retval; + m_combinedWhitelist = tmpMap; return m_combinedWhitelist; } |
