QWebSocketCorsAuthenticatorclass provides an authenticator object for Cross Origin Requests (CORS). 更多 …
QWebSocketCorsAuthenticatorclass is used in theoriginAuthenticationRequired()信号。类提供手段把所需信息传递回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 theoriginAuthenticationRequired()信号到槽。当来源 (origin()) is accepted, it callssetAllowed(true)注意
当凭借非浏览器客户端访问服务器时,校验来源没有多大意义,因为这种客户端可以设置它喜欢的任何来源的 Header 头。若是浏览器客户端,服务器应该校验来源的有效性。
另请参阅
WebSocket Security Considerations
QWebSocketServer
QWebSocketCorsAuthenticator
(
origin
)
¶
QWebSocketCorsAuthenticator(other)
origin – unicode
other
–
QWebSocketCorsAuthenticator
PySide2.QtWebSockets.QWebSocketCorsAuthenticator.
allowed
(
)
¶
bool
返回 true 若来源是允许的,否则返回 false。
注意
默认情况下,所有来源均被接受。
另请参阅
PySide2.QtWebSockets.QWebSocketCorsAuthenticator.
origin
(
)
¶
unicode
返回此身份验证器正在处理的有关来源。
PySide2.QtWebSockets.QWebSocketCorsAuthenticator.
setAllowed
(
allowed
)
¶
allowed
–
bool
允许或不允许来源。设置
allowed
为 true,将接受给定来源的连接请求。
设置
allowed
为 false,将拒绝连接请求。
注意
默认情况下,所有来源均被接受。
另请参阅
PySide2.QtWebSockets.QWebSocketCorsAuthenticator.
swap
(
other
)
¶
other
–
QWebSocketCorsAuthenticator
交换
other
与此身份验证器。
此操作非常快且从不失败。