mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 21:29:33 +02:00
Merge pull request #3236 from birarda/domain-server-auth
allow assignments to pull script without session cookie
This commit is contained in:
commit
d89a373e12
1 changed files with 33 additions and 32 deletions
|
@ -952,6 +952,39 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if this is a request for a scripted assignment (with a temp unique UUID)
|
||||||
|
const QString ASSIGNMENT_REGEX_STRING = QString("\\%1\\/(%2)\\/?$").arg(URI_ASSIGNMENT).arg(UUID_REGEX_STRING);
|
||||||
|
QRegExp assignmentRegex(ASSIGNMENT_REGEX_STRING);
|
||||||
|
|
||||||
|
if (connection->requestOperation() == QNetworkAccessManager::GetOperation
|
||||||
|
&& assignmentRegex.indexIn(url.path()) != -1) {
|
||||||
|
QUuid matchingUUID = QUuid(assignmentRegex.cap(1));
|
||||||
|
|
||||||
|
SharedAssignmentPointer matchingAssignment = _allAssignments.value(matchingUUID);
|
||||||
|
if (!matchingAssignment) {
|
||||||
|
// check if we have a pending assignment that matches this temp UUID, and it is a scripted assignment
|
||||||
|
PendingAssignedNodeData* pendingData = _pendingAssignedNodes.value(matchingUUID);
|
||||||
|
if (pendingData) {
|
||||||
|
matchingAssignment = _allAssignments.value(pendingData->getAssignmentUUID());
|
||||||
|
|
||||||
|
if (matchingAssignment && matchingAssignment->getType() == Assignment::AgentType) {
|
||||||
|
// we have a matching assignment and it is for the right type, have the HTTP manager handle it
|
||||||
|
// via correct URL for the script so the client can download
|
||||||
|
|
||||||
|
QUrl scriptURL = url;
|
||||||
|
scriptURL.setPath(URI_ASSIGNMENT + "/"
|
||||||
|
+ uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID()));
|
||||||
|
|
||||||
|
// have the HTTPManager serve the appropriate script file
|
||||||
|
return _httpManager.handleHTTPRequest(connection, scriptURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// request not handled
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
|
if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
|
||||||
if (url.path() == "/assignments.json") {
|
if (url.path() == "/assignments.json") {
|
||||||
// user is asking for json list of assignments
|
// user is asking for json list of assignments
|
||||||
|
@ -1068,38 +1101,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if this is a request for a scripted assignment (with a temp unique UUID)
|
|
||||||
const QString ASSIGNMENT_REGEX_STRING = QString("\\%1\\/(%2)\\/?$").arg(URI_ASSIGNMENT).arg(UUID_REGEX_STRING);
|
|
||||||
QRegExp assignmentRegex(ASSIGNMENT_REGEX_STRING);
|
|
||||||
|
|
||||||
if (assignmentRegex.indexIn(url.path()) != -1) {
|
|
||||||
QUuid matchingUUID = QUuid(assignmentRegex.cap(1));
|
|
||||||
|
|
||||||
SharedAssignmentPointer matchingAssignment = _allAssignments.value(matchingUUID);
|
|
||||||
if (!matchingAssignment) {
|
|
||||||
// check if we have a pending assignment that matches this temp UUID, and it is a scripted assignment
|
|
||||||
PendingAssignedNodeData* pendingData = _pendingAssignedNodes.value(matchingUUID);
|
|
||||||
if (pendingData) {
|
|
||||||
matchingAssignment = _allAssignments.value(pendingData->getAssignmentUUID());
|
|
||||||
|
|
||||||
if (matchingAssignment && matchingAssignment->getType() == Assignment::AgentType) {
|
|
||||||
// we have a matching assignment and it is for the right type, have the HTTP manager handle it
|
|
||||||
// via correct URL for the script so the client can download
|
|
||||||
|
|
||||||
QUrl scriptURL = url;
|
|
||||||
scriptURL.setPath(URI_ASSIGNMENT + "/"
|
|
||||||
+ uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID()));
|
|
||||||
|
|
||||||
// have the HTTPManager serve the appropriate script file
|
|
||||||
return _httpManager.handleHTTPRequest(connection, scriptURL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// request not handled
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (connection->requestOperation() == QNetworkAccessManager::PostOperation) {
|
} else if (connection->requestOperation() == QNetworkAccessManager::PostOperation) {
|
||||||
if (url.path() == URI_ASSIGNMENT) {
|
if (url.path() == URI_ASSIGNMENT) {
|
||||||
|
|
Loading…
Reference in a new issue