Skip to content

Commit bc6beaf

Browse files
authored
Merge pull request #2604 from nemozak1/develop
mirror consumer_id and client_id in database setup
2 parents 055fa68 + d5907ad commit bc6beaf

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,22 @@ Once Postgres is installed (On macOS, use `brew`):
206206

207207
1. Grant all on database `obpdb` to `obp`; (So OBP-API can create tables etc.)
208208

209+
#### For newer versions of postgres 16 and above, you need to follow the following instructions
210+
-- Connect to the sandbox database
211+
\c sandbox;
212+
213+
-- Grant schema usage and creation privileges
214+
GRANT USAGE ON SCHEMA public TO obp;
215+
GRANT CREATE ON SCHEMA public TO obp;
216+
217+
-- Grant all privileges on existing tables (if any)
218+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO obp;
219+
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO obp;
220+
221+
-- Grant privileges on future tables and sequences
222+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO obp;
223+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO obp;
224+
209225
1. Then, set the `db.url` in your Props:
210226

211227
```

obp-api/src/main/scripts/sql/create_oidc_user_and_views.sql

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@
8787

8888
-- OIDC user credentials
8989
-- ⚠️ SECURITY: Change this to a strong password (20+ chars, mixed case, numbers, symbols)
90-
\set OIDC_USER 'oidc_user'
91-
\set OIDC_PASSWORD 'lakij8777fagg'
90+
\set OIDC_USER "oidc_user"
91+
\set OIDC_PASSWORD '''lakij8777fagg'''
9292

9393
-- OIDC admin user credentials (for client administration)
9494
-- ⚠️ SECURITY: Change this to a strong password (20+ chars, mixed case, numbers, symbols)
95-
\set OIDC_ADMIN_USER 'oidc_admin'
96-
\set OIDC_ADMIN_PASSWORD 'fhka77uefassEE'
95+
\set OIDC_ADMIN_USER "oidc_admin"
96+
\set OIDC_ADMIN_PASSWORD '''fhka77uefassEE'''
9797

9898
-- =============================================================================
9999
-- 1. Connect to the OBP database
@@ -120,7 +120,7 @@ ALTER ROLE :OIDC_ADMIN_USER WITH PASSWORD :OIDC_ADMIN_PASSWORD;
120120

121121
-- Create the OIDC user with limited privileges
122122
CREATE USER :OIDC_USER WITH
123-
PASSWORD :'OIDC_PASSWORD'
123+
PASSWORD :OIDC_PASSWORD
124124
NOSUPERUSER
125125
NOCREATEDB
126126
NOCREATEROLE
@@ -134,7 +134,7 @@ ALTER USER :OIDC_USER CONNECTION LIMIT 10;
134134

135135
-- Create the OIDC admin user with limited privileges
136136
CREATE USER :OIDC_ADMIN_USER WITH
137-
PASSWORD :'OIDC_ADMIN_PASSWORD'
137+
PASSWORD :OIDC_ADMIN_PASSWORD
138138
NOSUPERUSER
139139
NOCREATEDB
140140
NOCREATEROLE
@@ -143,11 +143,12 @@ CREATE USER :OIDC_ADMIN_USER WITH
143143
NOREPLICATION
144144
NOBYPASSRLS;
145145

146-
-- need this so the admin can create rows
147-
GRANT USAGE, SELECT ON SEQUENCE consumer_id_seq TO :OIDC_ADMIN_USER;
146+
-- TODO: THIS IS NOT WORKING FOR SOME REASON, WE HAVE TO MANUALLY DO THIS LATER
147+
-- need this so the admin can create rows
148+
GRANT USAGE, SELECT ON SEQUENCE consumer_id_seq TO :OIDC_ADMIN_USER;
148149

149-
-- double check this
150-
GRANT USAGE, SELECT ON SEQUENCE consumer_id_seq TO oidc_admin;
150+
-- double check this
151+
GRANT USAGE, SELECT ON SEQUENCE consumer_id_seq TO oidc_admin;
151152

152153
-- Set connection limit for the OIDC admin user
153154
ALTER USER :OIDC_ADMIN_USER CONNECTION LIMIT 5;
@@ -202,14 +203,16 @@ DROP VIEW IF EXISTS v_oidc_clients CASCADE;
202203
CREATE VIEW v_oidc_clients AS
203204
SELECT
204205
key_c as client_id,
206+
key_c as consumer_id,
205207
secret as client_secret,
206208
redirecturl as redirect_uris,
207209
'authorization_code,refresh_token' as grant_types, -- Default OIDC grant types
208210
'openid,profile,email' as scopes, -- Default OIDC scopes
209211
name as client_name,
210212
'code' as response_types,
211213
'client_secret_post' as token_endpoint_auth_method,
212-
createdat as created_at
214+
createdat as created_at,
215+
consumerid
213216
FROM consumer
214217
WHERE isactive = true -- Only expose active consumers to OIDC service
215218
ORDER BY client_name;

0 commit comments

Comments
 (0)