diff options
author | Simon Rettberg | 2024-06-25 11:40:36 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-06-25 11:40:36 +0200 |
commit | 2ea077382d0500a6554018539a985e0eaf32a92a (patch) | |
tree | 9f76201947dafed4ed4ca15a2f73960e9c593774 /src/global.cpp | |
parent | Add allowed-shibboleth-domains config option to inject in website (diff) | |
download | slxgreeter-2ea077382d0500a6554018539a985e0eaf32a92a.tar.gz slxgreeter-2ea077382d0500a6554018539a985e0eaf32a92a.tar.xz slxgreeter-2ea077382d0500a6554018539a985e0eaf32a92a.zip |
Make shibboleth whitelist a folder which can contain multiple files
This way we can allow the user the create and specify multiple config
modules for shibboleth at once.
Diffstat (limited to 'src/global.cpp')
-rw-r--r-- | src/global.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/global.cpp b/src/global.cpp index ab2519b..91704f3 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -9,6 +9,7 @@ #include <QStringList> #include <QCryptographicHash> #include <QRegularExpression> +#include <QSet> bool Global::m_testMode = false; @@ -139,3 +140,29 @@ bool Global::isValidShibCreds(const QString &ustr, const QString &upass) && R_USER.match(ustr).hasMatch() && R_PASS.match(upass).hasMatch(); } + +QString Global::getCombinedIdpWhitelist() +{ + QDir configDir(QLatin1String("/opt/openslx/pam/shibboleth/whitelist")); + QFileInfoList fileInfoList = configDir.entryInfoList(QStringList() << "*.idp", QDir::Files); + + QSet<QString> list; + for (QFileInfo fileInfo : fileInfoList) { + QString filePath = fileInfo.absoluteFilePath(); + QFile f(filePath); + if (!f.open(QFile::ReadOnly)) + continue; + while (f.canReadLine()) { + list << QString::fromUtf8(f.readLine()); + } + f.close(); + } + QString retval; + for (const QString &s : list) { + if (!retval.isEmpty()) { + retval.append(QLatin1Char(' ')); + } + retval += s; + } + return retval; +} |