Skip to content

Commit

Permalink
fix: make username sanitization case-insensitive (graphile#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrandt committed Dec 10, 2021
1 parent 3092f44 commit 119ad86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
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

0 comments on commit 119ad86

Please sign in to comment.