Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/milky/network/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ class MilkyHttpHandler {
// Check access token for WebSocket connection
if (this.config.accessToken) {
const url = new URL(req.url!, `http://${req.headers.host}`)
const inputToken = url.searchParams.get('access_token')

let inputToken = ''
const authHeader = req.headers['authorization']
if (authHeader?.toLowerCase().startsWith('bearer ')) {
inputToken = authHeader.slice(7).trim()
this.ctx.logger.info('receive ws header token', inputToken)
} else {
inputToken = url.searchParams.get('access_token') ?? ''
}
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

if (!inputToken || inputToken !== this.config.accessToken) {
this.ctx.logger.warn('MilkyHttp', `${req.socket.remoteAddress} -> /event (Credentials invalid)`)
Expand Down
Loading