内容表

上一话题

QWebSocket

下一话题

QWebSocketProtocol

QWebSocketCorsAuthenticator

QWebSocketCorsAuthenticator class provides an authenticator object for Cross Origin Requests (CORS). 更多 …

Inheritance diagram of PySide2.QtWebSockets.QWebSocketCorsAuthenticator

概要

函数

详细描述

QWebSocketCorsAuthenticator class is used in the originAuthenticationRequired() 信号。类提供手段把所需信息传递回 QWebSocketServer . It provides applications with fine-grained control over which origin URLs are allowed and which aren’t. By default, every origin is accepted. To get fine-grained control, an application connects the originAuthenticationRequired() 信号到槽。当来源 ( origin() ) is accepted, it calls setAllowed (true)

注意

当凭借非浏览器客户端访问服务器时,校验来源没有多大意义,因为这种客户端可以设置它喜欢的任何来源的 Header 头。若是浏览器客户端,服务器应该校验来源的有效性。

另请参阅

WebSocket Security Considerations QWebSocketServer

class QWebSocketCorsAuthenticator ( origin )

QWebSocketCorsAuthenticator(other)

参数
PySide2.QtWebSockets.QWebSocketCorsAuthenticator. allowed ( )
返回类型

bool

返回 true 若来源是允许的,否则返回 false。

注意

默认情况下,所有来源均被接受。

另请参阅

setAllowed()

PySide2.QtWebSockets.QWebSocketCorsAuthenticator. origin ( )
返回类型

unicode

返回此身份验证器正在处理的有关来源。

PySide2.QtWebSockets.QWebSocketCorsAuthenticator. setAllowed ( allowed )
参数

allowed – bool

允许或不允许来源。设置 allowed 为 true,将接受给定来源的连接请求。

设置 allowed 为 false,将拒绝连接请求。

注意

默认情况下,所有来源均被接受。

另请参阅

allowed()

PySide2.QtWebSockets.QWebSocketCorsAuthenticator. swap ( other )
参数

other – QWebSocketCorsAuthenticator

交换 other 与此身份验证器。

此操作非常快且从不失败。