An open API service indexing awesome lists of open source software.

https://github.com/dvob/pg_dummy_validator

Postgres OAuth Dummy Validator Module
https://github.com/dvob/pg_dummy_validator

Last synced: 4 months ago
JSON representation

Postgres OAuth Dummy Validator Module

Awesome Lists containing this project

README

          

# PostgreSQL Dummy OAuth Validator Module

This repo contains a OAuth validator module to test and play around with the new OAuth feature in PostgreSQL 18.
A OAuth validator module is the shared library which performs the actual verification of the OAuth token. As a result it returns the authenticated user/role.
This dummy validator doesn't validate anything at all and authenticats all tokens. It returns the value of the token as user to PostgreSQL (e.g. if a client sends token `myapp` it will be authenticated as user/role `myapp`).

See:
- PostgreSQL OAuth Client Authentication: https://www.postgresql.org/docs/18/auth-oauth.html
- Implementation of OAuth Validator Modules: https://www.postgresql.org/docs/current/oauth-validators.html

Drivers:
- Go pgx: https://github.com/jackc/pgx/pull/2400

# Build
## Local
To build it you need a Postgres installation with header files (e.g. packge `postgresql-server-dev-18`). Alternatively you can build Postgres yourself (see below).
```
make
make install
```
## Docker
```
make docker-build
```

# Test
Run a test server.
## Local
Prepare cluster directory:
```
initdb -D mytest
cat <mytest/pg_hba.conf
local all all trust
host all all all oauth validator=dummy_validator issuer=https://example.com scope=
EOF

cat <>mytest/postgresql.conf
oauth_validator_libraries = 'dummy_validator'
EOF
```

Make sure dummy_validator.so is installed (`make install`).

Run:
```
pg_ctl -D mytest -l mytest.log start
```

Create user and database:
```
psql postgres <