21 lines
606 B
Bash
Executable File
21 lines
606 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<'EOSQL'
|
|
|
|
-- Create authenticator role (no-login, used by PostgREST)
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'authenticator') THEN
|
|
CREATE ROLE authenticator NOLOGIN;
|
|
END IF;
|
|
END
|
|
$$;
|
|
|
|
-- Grant authenticator usage on public schema and read access to all tables
|
|
GRANT USAGE ON SCHEMA public TO authenticator;
|
|
GRANT SELECT ON ALL TABLES IN SCHEMA public TO authenticator;
|
|
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO authenticator;
|
|
|
|
EOSQL
|