55 static QMutex lock(QMutex::Recursive);
56 static QMap<QString,WebSocketAuthentication> tokens;
58 QMutexLocker locker(&lock);
63 QMap<QString,WebSocketAuthentication>::iterator it = tokens.begin();
64 for ( ; it != tokens.end(); ++it)
65 if (it.value().m_timeStamp < tooold)
68 foreach (
const QString &expire, old)
69 tokens.remove(expire);
72 if (!Current.isEmpty())
74 if (tokens.contains(Current))
77 if (tokens.value(Current).m_host == Host)
79 tokens.remove(Current);
82 tokens.remove(Current);
83 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Host mismatch for websocket authentication"));
85 return QStringLiteral(
"ErroR");
89 QString uuid = QUuid::createUuid().toString().mid(1, 36);
quint64 GetMicrosecondCount(void)
Get the current system clock time in microseconds.
#define LOG(_MASK_, _LEVEL_, _STRING_)
A simple container for authenticaion tokens.
WebSocketAuthentication()
WebSocketAuthentication(quint64 Timestamp, const QString &Host)
static QString GetWebSocketToken(const QString &Host, const QString &Current=QString())
Retrieve an authentication token for the given request or validate a current token.