mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Prioritize access_token in searchparam over access_token in the cookies when using "strict" mode for websocket authentication (#22888)
* changes * prioritize query token if present * prioritize cookie over handshake * Create moody-bees-pay.md * Update moody-bees-pay.md --------- Co-authored-by: Brainslug <tim@brainslug.nl> Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
This commit is contained in:
5
.changeset/moody-bees-pay.md
Normal file
5
.changeset/moody-bees-pay.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@directus/api": patch
|
||||
---
|
||||
|
||||
Prioritized access_token in query over cookies for websocket authentication
|
||||
@@ -137,14 +137,14 @@ export default abstract class SocketController {
|
||||
const context: UpgradeContext = { request, socket, head };
|
||||
const sessionCookieName = env['SESSION_COOKIE_NAME'] as string;
|
||||
|
||||
if (cookies[sessionCookieName]) {
|
||||
const token = cookies[sessionCookieName] as string;
|
||||
if (this.authentication.mode === 'strict' || query['access_token']) {
|
||||
const token = query['access_token'] as string;
|
||||
await this.handleTokenUpgrade(context, token);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.authentication.mode === 'strict') {
|
||||
const token = query['access_token'] as string;
|
||||
if (cookies[sessionCookieName]) {
|
||||
const token = cookies[sessionCookieName] as string;
|
||||
await this.handleTokenUpgrade(context, token);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user