Skip to main content

Postgres Data Source

If the POSTGRES_CONNECTION_STRING environment variable is set, PADS will connect to the specified Postgres database.

Postgres triggers are configured to stream updates to the Go External Authorization Server in real time as changes are made to the connected Postgres database.

Grove Portal DB Driver Background


info

The database driver implemented is an extremely opinionated implementation designed for backwards compatibility with Grove's Portal.

The Grove Postgres Driver schema file uses a subset of tables from the existing Grove Portal database schema, allowing PATH to source its authorization data from the existing Grove Portal DB.

It converts the data stored in the portal_applications table and its associated tables into the proto.GatewayEndpoint format expected by PATH's Go External Authorization Server.

It also listens for updates to the Grove Portal DB and streams updates to the Go External Authorization Server in real time as changes are made to the connected Postgres database.

The full Grove Portal DB schema is defined in the Portal HTTP DB (PHD) repository.

Entity Relationship Diagram

This ERD shows the subset of tables from the full Grove Portal DB schema that are used by the Grove Postgres Driver in PADS.

SQLC Autogeneration


The Postgres Driver uses SQLC to automatically convert SQL definitions into Go code.

The process is started by running make gen_sqlc, which reads two main SQL files:

  1. grove_schema.sql: Defines the database structure
  2. grove_queries.sql: Contains the database queries

Using the configuration in sqlc.yaml, SQLC generates the corresponding Go code and outputs it to the postgres/grove/sqlc directory.

Additional Postgres Implementations

As mentioned above, this is an extremely opinionated implementation designed for backwards compatibility with Grove's Portal.

Pull requests are welcome to support alternative Postgres data sources.

The only requirement is that the gRPC service definition in gateway_endpoint.proto must be supported.

Alternatively, you may fork the PADS repository and implement your own data source.