mirror of
https://github.com/SrIzan10/hctv.git
synced 2026-06-06 00:56:56 +00:00
Add security validation and documentation for botAuth parameter
Co-authored-by: SrIzan10 <66965250+SrIzan10@users.noreply.github.com>
This commit is contained in:
@@ -47,8 +47,11 @@ app.get(
|
||||
let apiKey: string | null = null;
|
||||
if (authHeader && authHeader.startsWith('Bearer ')) {
|
||||
apiKey = authHeader.substring(7);
|
||||
} else if (botAuth) {
|
||||
apiKey = botAuth;
|
||||
} else if (botAuth && typeof botAuth === 'string' && botAuth.trim().length > 0) {
|
||||
// Validate botAuth query parameter format
|
||||
if (botAuth.startsWith('hctvb_')) {
|
||||
apiKey = botAuth;
|
||||
}
|
||||
}
|
||||
|
||||
if (apiKey) {
|
||||
|
||||
@@ -15,9 +15,11 @@ You'll need to provide authentication, which can be done by providing an `auth_s
|
||||
|
||||
<Aside type="tip">
|
||||
Bot accounts are now supported. You can choose to connect as a bot by providing a bot account's API key in one of two ways:
|
||||
- Using the `Authorization` header: `Bearer hctvb_xxxxxxx` (for server-side connections)
|
||||
- Using the `Authorization` header: `Bearer hctvb_xxxxxxx` (for server-side connections) **[Recommended]**
|
||||
- Using the `?botAuth=hctvb_xxxxxxx` query parameter (for browser-based connections, since browsers cannot set custom headers on WebSocket connections)
|
||||
|
||||
**Security Note:** When using the `?botAuth=` query parameter, be aware that query parameters may be logged in browser history, server logs, and proxy logs. Use the `Authorization` header method whenever possible. The query parameter method should only be used when connecting from a browser environment where headers cannot be set.
|
||||
|
||||
It is highly advised to use a bot account for any automated task, and to implement anything pointed out in this page.
|
||||
|
||||
</Aside>
|
||||
|
||||
Reference in New Issue
Block a user