Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make username sanitization case-insensitive (#284) #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions @app/db/migrations/committed/000001.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--! Previous: -
--! Hash: sha1:eaf2866060caa0bba319236017c15a40d37a7815
--! Hash: sha1:fed7686b198e84812a6712d8b4da5add87a5f38f

--! split: 0001-reset.sql
/*
Expand Down Expand Up @@ -1369,10 +1369,11 @@ begin
where not exists(
select 1
from app_public.users
where users.username = (
-- Compare using lowercase, as username column is case-insensitive
where lower(users.username) = (
case
when i = 0 then v_username
else v_username || i::text
when i = 0 then lower(v_username)
else lower(v_username) || i::text
end
)
)
Expand Down
13 changes: 7 additions & 6 deletions data/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- PostgreSQL database dump
--

-- Dumped from database version 13.4 (Ubuntu 13.4-0ubuntu0.21.04.1)
-- Dumped by pg_dump version 13.4 (Ubuntu 13.4-0ubuntu0.21.04.1)
-- Dumped from database version 13rc1 (Debian 13~rc1-1.pgdg100+1)
-- Dumped by pg_dump version 13.4 (Debian 13.4-3)

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -451,10 +451,11 @@ begin
where not exists(
select 1
from app_public.users
where users.username = (
-- Compare using lowercase, as username column is case-insensitive
where lower(users.username) = (
case
when i = 0 then v_username
else v_username || i::text
when i = 0 then lower(v_username)
else lower(v_username) || i::text
end
)
)
Expand Down Expand Up @@ -2497,7 +2498,7 @@ GRANT USAGE ON SCHEMA app_public TO graphile_starter_visitor;
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: -
--

REVOKE ALL ON SCHEMA public FROM postgres;
REVOKE ALL ON SCHEMA public FROM ark_starter;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO graphile_starter;
GRANT USAGE ON SCHEMA public TO graphile_starter_visitor;
Expand Down