mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
hook domain-server to user DomainServerWebSessionData class
This commit is contained in:
parent
e75ed2c4fa
commit
f78a1f7033
4 changed files with 39 additions and 7 deletions
|
@ -43,7 +43,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
|||
_networkReplyUUIDMap(),
|
||||
_sessionAuthenticationHash(),
|
||||
_webAuthenticationStateSet(),
|
||||
_cookieProfileJSONHash(),
|
||||
_cookieSessionHash(),
|
||||
_settingsManager()
|
||||
{
|
||||
setOrganizationName("High Fidelity");
|
||||
|
@ -1281,10 +1281,10 @@ bool DomainServer::isAuthenticatedRequest(HTTPConnection* connection, const QUrl
|
|||
cookieUUID = cookieUUIDRegex.cap(1);
|
||||
}
|
||||
|
||||
if (!cookieUUID.isNull() && _cookieProfileJSONHash.contains(cookieUUID)) {
|
||||
if (!cookieUUID.isNull() && _cookieSessionHash.contains(cookieUUID)) {
|
||||
// pull the QJSONObject for the user with this cookie UUID
|
||||
QJsonObject profileObject = _cookieProfileJSONHash.value(cookieUUID);
|
||||
QString profileUsername = profileObject.value("username").toString();
|
||||
DomainServerWebSessionData sessionData = _cookieSessionHash.value(cookieUUID);
|
||||
QString profileUsername = sessionData.getUsername();
|
||||
|
||||
if (_argumentVariantMap.value(ADMIN_USERS_CONFIG_KEY).toJsonValue().toArray().contains(profileUsername)) {
|
||||
// this is an authenticated user
|
||||
|
@ -1404,7 +1404,7 @@ Headers DomainServer::setupCookieHeadersFromProfileReply(QNetworkReply* profileR
|
|||
QJsonDocument profileDocument = QJsonDocument::fromJson(profileReply->readAll());
|
||||
|
||||
// add the profile to our in-memory data structure so we know who the user is when they send us their cookie
|
||||
_cookieProfileJSONHash.insert(cookieUUID, profileDocument.object()["data"].toObject()["user"].toObject());
|
||||
_cookieSessionHash.insert(cookieUUID, DomainServerWebSessionData(profileDocument));
|
||||
|
||||
// setup expiry for cookie to 1 month from today
|
||||
QDateTime cookieExpiry = QDateTime::currentDateTimeUtc().addMonths(1);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <LimitedNodeList.h>
|
||||
|
||||
#include "DomainServerSettingsManager.h"
|
||||
#include "DomainServerWebSessionData.h"
|
||||
#include "WalletTransaction.h"
|
||||
|
||||
#include "PendingAssignedNodeData.h"
|
||||
|
@ -115,7 +116,7 @@ private:
|
|||
QHash<QUuid, QString> _sessionAuthenticationHash;
|
||||
|
||||
QSet<QUuid> _webAuthenticationStateSet;
|
||||
QHash<QUuid, QJsonObject> _cookieProfileJSONHash;
|
||||
QHash<QUuid, DomainServerWebSessionData> _cookieSessionHash;
|
||||
|
||||
DomainServerSettingsManager _settingsManager;
|
||||
};
|
||||
|
|
|
@ -14,6 +14,13 @@
|
|||
|
||||
#include "DomainServerWebSessionData.h"
|
||||
|
||||
DomainServerWebSessionData::DomainServerWebSessionData() :
|
||||
_username(),
|
||||
_roles()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DomainServerWebSessionData::DomainServerWebSessionData(const QJsonDocument& profileDocument) :
|
||||
_roles()
|
||||
{
|
||||
|
@ -23,4 +30,23 @@ DomainServerWebSessionData::DomainServerWebSessionData(const QJsonDocument& prof
|
|||
foreach(const QJsonValue& rolesValue, profileDocument.object()["user"].toObject()["roles"].toObject()) {
|
||||
_roles.insert(rolesValue.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DomainServerWebSessionData::DomainServerWebSessionData(const DomainServerWebSessionData& otherSessionData) {
|
||||
_username = otherSessionData._username;
|
||||
_roles = otherSessionData._roles;
|
||||
}
|
||||
|
||||
DomainServerWebSessionData& DomainServerWebSessionData::operator=(const DomainServerWebSessionData& otherSessionData) {
|
||||
DomainServerWebSessionData temp(otherSessionData);
|
||||
swap(temp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void DomainServerWebSessionData::swap(DomainServerWebSessionData& otherSessionData) {
|
||||
using std::swap;
|
||||
|
||||
swap(_username, otherSessionData._username);
|
||||
swap(_roles, otherSessionData._roles);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,17 @@
|
|||
class DomainServerWebSessionData : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DomainServerWebSessionData();
|
||||
DomainServerWebSessionData(const QJsonDocument& profileDocument);
|
||||
DomainServerWebSessionData(const DomainServerWebSessionData& otherSessionData);
|
||||
DomainServerWebSessionData& operator=(const DomainServerWebSessionData& otherSessionData);
|
||||
|
||||
const QString& getUsername() const { return _username; }
|
||||
const QSet<QString>& getRoles() const { return _roles; }
|
||||
|
||||
private:
|
||||
void swap(DomainServerWebSessionData& otherSessionData);
|
||||
|
||||
QString _username;
|
||||
QSet<QString> _roles;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue