Define PostgreSQL API Exposure in Safegres
Dan Lynch
List the schemas your app serves, the database roles it uses, and any roles that connect directly. A name like app_public doesn't make a schema public. For the PGPM lab, add this at the end of safegres.config.js:
javascriptmodule.exports.exposure = { schemas: ['app_public'], roles: ['authenticated'], };
Use your app's actual schemas and roles. If unauthenticated requests assume a database role, add it to exposure.anonRoles. Direct logins get their own scores in the next lesson.
bashpnpm exec safegres print-config --explain pnpm exec safegres audit --verbose
Check the resolved exposure in the audit. Top-level schemas and excludeSchemas filter what gets analyzed; exposure.schemas changes what gets scored without dropping internal findings. Use --config path/to/config.json if Safegres picks up a different config.
Next, compare API and direct database risk without changing any grants.

