Skip to content

Commit f8548f1

Browse files
committed
refactor: OIDC Revoke before dropping
1 parent 2468d99 commit f8548f1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

obp-api/src/main/scripts/sql/OIDC/cre_OIDC_ADMIN_USER.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM :OIDC_ADMIN_USER;
1111
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM :OIDC_ADMIN_USER;
1212
REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM :OIDC_ADMIN_USER;
13+
REVOKE USAGE ON SCHEMA public FROM :OIDC_ADMIN_USER;
14+
REVOKE CONNECT ON DATABASE :DB_NAME FROM :OIDC_ADMIN_USER;
1315

1416
-- Drop the user if they already exist (for re-running the script)
1517
DROP USER IF EXISTS :OIDC_ADMIN_USER;

obp-api/src/main/scripts/sql/OIDC/cre_OIDC_USER.sql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM :OIDC_USER;
1313

1414

1515
-- Drop the user if they already exist (for re-running the script)
16+
-- First revoke all privileges to avoid dependency errors
17+
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM :OIDC_USER;
18+
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM :OIDC_USER;
19+
REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM :OIDC_USER;
20+
REVOKE USAGE ON SCHEMA public FROM :OIDC_USER;
21+
REVOKE CONNECT ON DATABASE :DB_NAME FROM :OIDC_USER;
22+
1623
DROP USER IF EXISTS :OIDC_USER;
1724

1825
-- Create the OIDC user with limited privileges
@@ -28,12 +35,12 @@ CREATE USER :OIDC_USER WITH
2835

2936

3037

31-
-- Grant CONNECT privilege on the database
32-
GRANT CONNECT ON DATABASE :DB_NAME TO :OIDC_USER;
33-
3438
-- Grant USAGE on the public schema (or specific schema where authuser exists)
3539
GRANT USAGE ON SCHEMA public TO :OIDC_USER;
3640

41+
-- Grant CONNECT privilege on the database
42+
GRANT CONNECT ON DATABASE :DB_NAME TO :OIDC_USER;
43+
3744
-- Set default privileges to prevent future access to new objects that this user might create
3845
ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON TABLES FROM :OIDC_USER;
3946
ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON SEQUENCES FROM :OIDC_USER;

0 commit comments

Comments
 (0)