Auf dieser Seite

QWebSocketCorsAuthenticator Class

Die Klasse „QWebSocketCorsAuthenticator“ stellt ein Authentifizierungsobjekt für Cross-Origin-Anfragen (CORS) bereit. Mehr...

Header: #include <QWebSocketCorsAuthenticator>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebSockets)
target_link_libraries(mytarget PRIVATE Qt6::WebSockets)
qmake: QT += websockets

Öffentliche Funktionen

QWebSocketCorsAuthenticator(const QString &origin)
QWebSocketCorsAuthenticator(const QWebSocketCorsAuthenticator &other)
QWebSocketCorsAuthenticator(QWebSocketCorsAuthenticator &&other)
~QWebSocketCorsAuthenticator()
bool allowed() const
QString origin() const
void setAllowed(bool allowed)
void swap(QWebSocketCorsAuthenticator &other)
QWebSocketCorsAuthenticator &operator=(QWebSocketCorsAuthenticator &&other)
QWebSocketCorsAuthenticator &operator=(const QWebSocketCorsAuthenticator &other)

Ausführliche Beschreibung

Die Klasse `QWebSocketCorsAuthenticator` wird im Signal ` originAuthenticationRequired()` verwendet. Die Klasse bietet eine Möglichkeit, die erforderlichen Informationen an den ` QWebSocketServer` zurückzugeben. Sie ermöglicht Anwendungen eine detaillierte Steuerung darüber, welche Ursprungs-URLs zugelassen werden und welche nicht. Standardmäßig wird jeder Ursprung akzeptiert. Um eine detaillierte Kontrolle zu erhalten, verbindet eine Anwendung das Signal „ originAuthenticationRequired()“ mit einem Slot. Wenn der Ursprung (QWebSocketCorsAuthenticator::origin()) akzeptiert wird, ruft sie „ QWebSocketCorsAuthenticator::setAllowed(true)“ auf.

Hinweis: Die Überprüfung der Herkunft ist wenig sinnvoll, wenn der Zugriff auf den Server über einen Nicht-Browser-Client erfolgt, da dieser Client einen beliebigen Herkunfts-Header setzen kann. Im Falle eines Browser-Clients SOLLTE der Server die Gültigkeit der Herkunft überprüfen.

Siehe auch „WebSocket Security Considerations “ und „ QWebSocketServer “.

Dokumentation der Mitgliedsfunktionen

[explicit] QWebSocketCorsAuthenticator::QWebSocketCorsAuthenticator(const QString &origin)

Erstellt ein neues QCorsAuthenticator-Objekt mit dem angegebenen „ origin “.

Hinweis: Standardmäßig gibt ` allowed()` den Wert „true“ zurück. Das bedeutet, dass standardmäßig jede Herkunft akzeptiert wird.

[explicit] QWebSocketCorsAuthenticator::QWebSocketCorsAuthenticator(const QWebSocketCorsAuthenticator &other)

Erstellt eine Kopie von „ other “.

[noexcept] QWebSocketCorsAuthenticator::QWebSocketCorsAuthenticator(QWebSocketCorsAuthenticator &&other)

Erstellt einen `QWebSocketCorsAuthenticator` und richtet ihn so aus, dass er auf dasselbe Objekt verweist, auf das zuvor ` other ` verwiesen hat.

[noexcept] QWebSocketCorsAuthenticator::~QWebSocketCorsAuthenticator()

Löscht das Objekt.

bool QWebSocketCorsAuthenticator::allowed() const

Gibt „true“ zurück, wenn die Herkunft zulässig ist, andernfalls „false“.

Hinweis: Standardmäßig werden alle Ursprünge akzeptiert.

Siehe auch „ setAllowed()“.

QString QWebSocketCorsAuthenticator::origin() const

Gibt den Ursprung zurück, den dieser Authentifikator verwaltet.

void QWebSocketCorsAuthenticator::setAllowed(bool allowed)

Erlaubt oder verbietet die Herkunft. Wenn „ allowed “ auf „true“ gesetzt wird, wird die Verbindungsanfrage für die angegebene Herkunft akzeptiert.

Wird „ allowed “ auf „false“ gesetzt, wird die Verbindungsanfrage abgelehnt.

Hinweis: Standardmäßig werden alle Ursprünge akzeptiert.

Siehe auch „ allowed()“.

[noexcept] void QWebSocketCorsAuthenticator::swap(QWebSocketCorsAuthenticator &other)

Ersetzt „ other “ durch diesen Authentifikator.

Dieser Vorgang ist sehr schnell und schlägt niemals fehl.

[noexcept] QWebSocketCorsAuthenticator &QWebSocketCorsAuthenticator::operator=(QWebSocketCorsAuthenticator &&other)

Weist dieser Instanz „ other “ zu.

QWebSocketCorsAuthenticator &QWebSocketCorsAuthenticator::operator=(const QWebSocketCorsAuthenticator &other)

Weist diesem Authentifizierungsobjekt „ other “ zu.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.