Skip to content

Commit

Permalink
Merge pull request #72 from sev-2/feat/grant-extras
Browse files Browse the repository at this point in the history
Add extra grants for storage when create new role
  • Loading branch information
vani-rf authored Sep 25, 2024
2 parents b67fde0 + 8369882 commit 8695817
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pkg/supabase/query/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,20 @@ func BuildCreateRoleQuery(role objects.Role) string {
BEGIN
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '%s') THEN
CREATE ROLE %s WITH %s;
GRANT %s TO authenticator;
GRANT anon TO %s;
END IF;
END $$;
%s
GRANT %s TO authenticator;
COMMIT;`,
role.Name, role.Name, strings.Join(createRolClauses, "\n"),
configClause, role.Name,
role.Name,
role.Name,
strings.Join(createRolClauses, "\n"),
role.Name,
role.Name,
configClause,
role.Name,
)
}

Expand Down Expand Up @@ -173,5 +180,12 @@ func BuildUpdateRoleQuery(newRole objects.Role, updateRoleParam objects.UpdateRo
}

func BuildDeleteRoleQuery(role objects.Role) string {
return fmt.Sprintf("DROP ROLE %s;", role.Name)
return fmt.Sprintf(`
REVOKE %s FROM authenticator;
REVOKE anon FROM %s;
DROP ROLE %s;`,
role.Name,
role.Name,
role.Name,
)
}

0 comments on commit 8695817

Please sign in to comment.