username sanitization is case sensitive; column is citext
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 50/100
調査の方向性
報告された変更は @app/db/migrations/committed/000001.sql の app_private.register_user 内にあります。まず、ユーザー名の一意性を確認するクエリと周辺の migration を読みます。大文字と小文字が異なる既存のユーザー名を使った OAuth 登録のケースを再現し、その後、citext 制約の下でサニタイズ処理が競合しないユーザー名を選択することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Summary
Creating a new user using oauth fails in case there is already the same username with different case (ie. existing: peter, newly registering: Peter)
Steps to reproduce
- create an account with same username as your github username, but in different case (in my case, HYDRANDT would do)
- sign out
- attempt to sign in using github
- enjoy blue screen "An unknown error occurred"
Expected results
Username sanitization should be case insensitive and username should be sanitized to hydrandt1
Actual results
HYDRANDT and hydrandt are deemed non identical, number is not appended, and inserting a new user fails, as username column on app_public.users is type citext.
Additional context
- problem is in the initial mutation, https://github.com/graphile/starter/blob/main/%40app/db/migrations/committed/000001.sql, in
app_private.register_user:
-- Sanitise the username, and make it unique if necessary.
...
select (
case
when i = 0 then v_username
else v_username || i::text
end
) into v_username from generate_series(0, 1000) i
where not exists(
select 1
from app_public.users
where users.username = (
case
when i = 0 then v_username
else v_username || i::text
end
)
)
limit 1;
Possible Solution
Convert username using lower() while checking for uniqueness:
select (
case
when i = 0 then v_username
else v_username || i::text
end
) into v_username from generate_series(0, 1000) i
where not exists(
select 1
from app_public.users
-- comparing using lowercase to make sure the username is unique (username column is citext -> constraint is not case sensitive)
where lower(users.username) = (
case
when i = 0 then lower(v_username)
else lower(v_username) || i::text
end
)
)
limit 1;
- 主要言語
- TypeScript
- スター
- 1.8k
- フォーク
- 226
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
graphile/starter のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
🐛 bug help wanted
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 18/100
-
TFA & RBACオープン
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
graphile/starter の issue をすべて見る
似ている issue
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsオープンbug triage:owned
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
directus/directus#28558 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
review: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
1lck/Lithe-IDEA#2432 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
cloudflare/workers-sdk#17189 ·
メンテナーはふだん 1 日以内に返信