A client reauth over the same socket should not count against their max connections
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
調査の方向性
lib/listener.js の Sockets.prototype.auth() から始めてください。issue では、再認証時に同じ socket がユーザーのインデックスに追加される箇所として特定されています。auth.index を有効にし、maxConnectionsPerUser を 2 に設定した、issue の再現テストを使用してください。1 つの開いた socket で再認証を繰り返しても接続数の上限を超えず、一方で別々の接続は引き続きカウントされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Runtime
node
Runtime version
v24.18.1
Module version
v14.0.1
Last module version without issue
N/A
Used with
hapi application
Any other relevant information
See https://github.com/hapijs/nes/pull/341. I commented with a test that reproduces the issue on master:
it('does not count reauthentication towards the connections limit', async () => {
const server = Hapi.server();
server.auth.scheme('custom', internals.implementation);
server.auth.strategy('default', 'custom');
server.auth.default('default');
await server.register({ plugin: Nes, options: { auth: { index: true, maxConnectionsPerUser: 2 } } });
await server.start();
const client = new Nes.Client(getUri(server.info));
await client.connect({ reconnect: false, auth: { headers: { authorization: 'Custom john' } } });
await client.reauthenticate({ headers: { authorization: 'Custom john' } });
// a reauth is not a new connection
await expect(client.reauthenticate({ headers: { authorization: 'Custom john' } })).to.not.reject();
client.disconnect();
await server.stop();
});
What are you trying to achieve or the steps to reproduce?
With auth.index: true, every reauthenticate() on an open connection pushes the same socket onto the user's index array again. Sockets.prototype.auth() in lib/listener.js doesn't check whether it's already there.
What was the result you got?
Multiple reauths due to token refresh can lead to disconnections due to hitting configured maxConnectionsPerUser when user only has 1 connection open.
An additional side effect is that a broadcast() targeted at a user will cause them to receive duplicate messages due to their socket being duplicated in the _byUser array.
What result did you expect?
I would expect only true connections (multiple tabs open for example) would count towards the limit.
- 主要言語
- JavaScript
- スター
- 502
- フォーク
- 85
- 平均マージ
- 16日 16時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hapijs/nes のほかの issue
-
Listener does not correctly handle optional & wildcard routes.再び着手できるかも @damusix が 219 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
-
support
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
support
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
似ている issue
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
open-webui/open-webui#33196 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
area: apple-music area: build-release bug effort: small priority: high
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ChristianTabor/Argon#32 ·
メンテナーはふだん 1 日以内に返信
-
0️⃣ phase/new
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100