File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,14 @@ import { registerYSocketIOServer } from './socketio.js'
88import http from 'http'
99import { randomUUID } from 'crypto'
1010
11- const skipAuth = env . getConf ( 'no-auth' ) === 'true'
12-
13- const wsServerPublicKey = await ecdsa . importKeyJwk (
14- json . parse ( env . ensureConf ( 'auth-public-key' ) )
15- )
11+ const authPublicKey = env . getConf ( 'auth-public-key' )
12+ /** @type {CryptoKey | null } */
13+ let wsServerPublicKey = null
14+ if ( authPublicKey ) {
15+ wsServerPublicKey = await ecdsa . importKeyJwk (
16+ json . parse ( env . ensureConf ( 'auth-public-key' ) )
17+ )
18+ }
1619
1720/**
1821 * @param {Object } opts
@@ -34,7 +37,7 @@ export const createYSocketIOServer = async ({
3437 const server = await registerYSocketIOServer ( io , store , {
3538 redisPrefix,
3639 authenticate : async ( socket ) => {
37- if ( skipAuth ) return { userid : randomUUID ( ) . toString ( ) }
40+ if ( ! wsServerPublicKey ) return { userid : randomUUID ( ) . toString ( ) }
3841 const token = socket . handshake . query . yauth
3942 if ( ! token ) return null
4043 // verify that the user has a valid token
You can’t perform that action at this time.
0 commit comments