-
-
Save sahil1/d1d7bec423eb72e9e01c4fab3c155a79 to your computer and use it in GitHub Desktop.
Revisions
-
sahil1 revised this gist
Aug 8, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ GRANT ALL privileges ON database mydatabasename TO sahil; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO sahil; -- Change password ALTER USER sahil WITH ENCRYPTED PASSWORD 'newsecret'; --------------------------------------- --------------------------------------- -- List all users -
sahil1 revised this gist
Aug 8, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,8 @@ GRANT readaccess TO sahil; GRANT ALL privileges ON database mydatabasename TO sahil; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO sahil; -- Change password ALTER USER sahil WITH ENCRYPTED PASSWORD 'newsecret' --------------------------------------- --------------------------------------- -- List all users -
sahil1 revised this gist
Aug 8, 2019 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,9 +9,13 @@ GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; -- Create a final user with password CREATE USER sahil WITH ENCRYPTED PASSWORD 'secret'; GRANT readaccess TO sahil; -- Grant all priviliges on all tables GRANT ALL privileges ON database mydatabasename TO sahil; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO sahil; --------------------------------------- --------------------------------------- -- List all users -
sahil1 revised this gist
Aug 8, 2019 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,8 +14,10 @@ GRANT readaccess TO sahil; --------------------------------------- --------------------------------------- -- List all users SELECT * FROM pg_user; -- Query user details SELECT u.usename AS "User name", u.usesysid AS "User ID", CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('superuser, create database' AS pg_catalog.text) @@ -26,7 +28,7 @@ SELECT u.usename AS "User name", FROM pg_catalog.pg_user u ORDER BY 1; -- Query roles SELECT r.rolname, r.rolsuper, r.rolinherit, r.rolcreaterole, r.rolcreatedb, r.rolcanlogin, r.rolconnlimit, r.rolvaliduntil, -
sahil1 revised this gist
Aug 8, 2019 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,4 +24,18 @@ SELECT u.usename AS "User name", ELSE CAST('' AS pg_catalog.text) END AS "Attributes" FROM pg_catalog.pg_user u ORDER BY 1; -- Query Roles SELECT r.rolname, r.rolsuper, r.rolinherit, r.rolcreaterole, r.rolcreatedb, r.rolcanlogin, r.rolconnlimit, r.rolvaliduntil, ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) AS memberof , r.rolreplication , r.rolbypassrls FROM pg_catalog.pg_roles r WHERE r.rolname !~ '^pg_' ORDER BY 1; -
sahil1 revised this gist
Aug 8, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,8 +9,8 @@ GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; -- Create a final user with password CREATE USER sahil WITH PASSWORD 'secret'; GRANT readaccess TO sahil; --------------------------------------- --------------------------------------- -
sahil1 revised this gist
Aug 8, 2019 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,3 +11,17 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; -- Create a final user with password CREATE USER tomek WITH PASSWORD 'secret'; GRANT readaccess TO tomek; --------------------------------------- --------------------------------------- -- Query Users SELECT u.usename AS "User name", u.usesysid AS "User ID", CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('superuser, create database' AS pg_catalog.text) WHEN u.usesuper THEN CAST('superuser' AS pg_catalog.text) WHEN u.usecreatedb THEN CAST('create database' AS pg_catalog.text) ELSE CAST('' AS pg_catalog.text) END AS "Attributes" FROM pg_catalog.pg_user u ORDER BY 1; -
oinopion created this gist
Oct 5, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ -- Create a group CREATE ROLE readaccess; -- Grant access to existing tables GRANT USAGE ON SCHEMA public TO readaccess; GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; -- Grant access to future tables ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; -- Create a final user with password CREATE USER tomek WITH PASSWORD 'secret'; GRANT readaccess TO tomek;