create omnivore_admin role and allow omnivore_admin to delete all users

This commit is contained in:
Hongbo Wu 2023-10-25 14:36:15 +08:00
parent dddb51f7d5
commit e6f378f8fe
3 changed files with 40 additions and 1 deletions

View file

@ -23,12 +23,16 @@ describe('User Service Router', () => {
email: 'user_1@omnivore.app',
status: StatusType.Deleted,
updatedAt: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2), // 2 days ago
source: 'GOOGLE',
sourceUserId: '123',
},
{
name: 'user_2',
email: 'user_2@omnivore.app',
status: StatusType.Deleted,
updatedAt: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2), // 2 days ago
source: 'GOOGLE',
sourceUserId: '456',
},
])
toDeleteUserIds = users.map((u) => u.id)
@ -50,7 +54,7 @@ describe('User Service Router', () => {
}
await request
.post('/api/user/cleanup?token=' + token)
.post('/svc/pubsub/user/cleanup?token=' + token)
.send(data)
.expect(200)

View file

@ -0,0 +1,19 @@
-- Type: DO
-- Name: create_omnivore_admin_role
-- Description: Create omnivore_admin role with admin permissions
BEGIN;
CREATE ROLE omnivore_admin;
GRANT omnivore_admin TO app_user;
GRANT ALL PRIVILEGES ON SCHEMA omnivore TO omnivore_admin;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA omnivore TO omnivore_admin;
CREATE POLICY user_admin_policy on omnivore.user
FOR ALL
TO omnivore_admin
USING (true);
COMMIT;

View file

@ -0,0 +1,16 @@
-- Type: UNDO
-- Name: create_omnivore_admin_role
-- Description: Create omnivore_admin role with admin permissions
BEGIN;
DROP POLICY user_admin_policy ON omnivore.user;
REVOKE ALL PRIVILEGES on omnivore.user from omnivore_admin;
REVOKE ALL PRIVILEGES on SCHEMA omnivore from omnivore_admin;
DROP OWNED BY omnivore_admin;
DROP ROLE IF EXISTS omnivore_admin;
COMMIT;