我一直在試圖從AWS PostgreSQL實例中刪除組角色,但我陷入了困境。我已經成功刪除了組中的所有依賴項,除了6以外,我不知道這些依賴項可能是什麼。我會解釋我試圖用來找到這些缺失的特權,我真的很感謝有關我下一步可以看到的方向。這些步驟中的每一個都關於所有的實例內的數據庫和模式來執行:PostgreSQL - 查找組的所有權限
我用下面的代碼來從組撤銷所有特權
REVOKE ALL ON DATABASE {dbname} FROM GROUP "Application_Access"; REVOKE ALL ON SCHEMA public FROM GROUP "Application_Access"; REVOKE ALL ON ALL TABLES IN SCHEMA public FROM GROUP "Application_Access"; REVOKE ALL ON ALL FUNCTIONS IN SCHEMA public FROM GROUP "Application_Access"; REVOKE ALL ON ALL SEQUENCES IN SCHEMA public FROM GROUP "Application_Access";
我用PSQL命令列出所有的對象和他們的特權,這是我發現
- \ Z =沒有上市Application_Access
- \杜和\ DG = Application_Access - 無繼承,無法登錄,會員{}
- \ d =由OurAdmin擁有的所有關係
- \ DB =由rdsadmin擁有的所有表空間(AWS管理)
- \ dtisv =無
- \ DDP =此命令是顯示Application_Access Results of \ddp Command
我明白\ DDP顯示了未來的數據庫添加默認權限的人。我試圖運行ALTER PRIVILEGES命令。它迫使我讓自己成爲Application_Access的成員(錯誤:必須是角色的成員,爲什麼?!?)才能運行該命令。這將我的所有權限重新分配給了Application_Access,我又回到了原來的位置。
ALTER DEFAULT PRIVILEGES ON ROLE "Application_Access" REVOKE ALL ON DATABASE {dbname} FROM "Application_Access"; ALTER DEFAULT PRIVILEGES ON ROLE "Application_Access" REVOKE ALL ON ALL SCHEMAS FROM "Application_Access"; ALTER DEFAULT PRIVILEGES ON ROLE "Application_Access" REVOKE ALL ON TABLES FROM "Application_Access"; ALTER DEFAULT PRIVILEGES ON ROLE "Application_Access" REVOKE ALL ON FUNCTIONS FROM "Application_Access"; ALTER DEFAULT PRIVILEGES ON ROLE "Application_Access" REVOKE ALL ON SEQUENCES FROM "Application_Access";
- 我重新所有我前面的步驟,但是,現在,當我上運行的所有數據庫\ DDP,還增加了前3行中,您所附加的圖片中看到。
我有一個腳本,我發現並更改了它以顯示每個數據庫上的所有權限。我可以通過它來簡化搜索。它沒有將Application_Access顯示爲與任何對象關聯。
SELECT relacl , SUBSTRING( CASE WHEN strpos('r', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', SELECT' ELSE '' END || CASE WHEN strpos('w', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', UPDATE' ELSE '' END || CASE WHEN strpos('a', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', INSERT' ELSE '' END || CASE WHEN strpos('d', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', DELETE' ELSE '' END || CASE WHEN strpos('R', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', RULE' ELSE '' END || CASE WHEN strpos('x', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', REFERENCES' ELSE '' END || CASE WHEN strpos('t', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', TRIGGER' ELSE '' END || CASE WHEN strpos('X', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', EXECUTE' ELSE '' END || CASE WHEN strpos('U', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', USAGE' ELSE '' END || CASE WHEN strpos('C', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', CREATE' ELSE '' END || CASE WHEN strpos('T', SPLIT_PART(SPLIT_PART(ARRAY_TO_STRING(RELACL, '|'), pu.groname, 2) , '/', 1)) > 0 THEN ', TEMPORARY' ELSE '' END , 3,10000) || namespace ||'.'|| item ||' TO '|| pu.groname ||' ;' AS grantsql FROM (SELECT use.usename AS subject ,nsp.nspname AS namespace ,cls.relname AS item ,cls.relkind AS type ,use2.usename AS owner ,cls.relacl FROM pg_user use CROSS JOIN pg_class cls LEFT JOIN pg_namespace nsp ON cls.relnamespace = nsp.oid LEFT JOIN pg_user use2 ON cls.relowner = use2.usesysid WHERE cls.relowner = use.usesysid AND nsp.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema') ORDER BY subject ,namespace ,item) as x JOIN pg_group pu ON array_to_string(relacl, '|') LIKE '%'|| pu.groname ||'%' WHERE relacl IS NOT NULL AND relacl::text LIKE '%Application%' ORDER BY 2
***根據您在上面看到的一切,還有什麼人能想到的,我離開了,或者沒做正確/完全?我如何解決默認權限 - ALTER PRIVILEGES REVOKE ALL都不起作用。感謝您的幫助。