PostgreSQL and Pointsharp IdP

This guide walks through the full setup of PostgreSQL and two Pointsharp IdP instances for a production-ready high-availability environment.

Preparations

Prepare your hosts.

Database

db-01: 10.50.0.41

db-02: 10.50.0.42

Pointsharp IdP

psidp-01: 10.50.0.31

psidp-02: 10.50.0.32

Ensure all are on the same network and resolvable via /etc/hosts or DNS.

DB_VENDOR

postgres, postgreSQL

DB_NAME

psidpdb

DB_USERNAME

psidpuser

Install and configure PostgreSQL

  1. Install postgreSQL:

    $ sudo apt update && sudo apt install -y postgresql
  2. Switch to the postgres user:

    $ sudo -i -u postgres
  3. Create a database and user:

    psql
    CREATE DATABASE psidpdb;
    CREATE USER psidpuser WITH PASSWORD 'StrongPassword123!';
    GRANT ALL PRIVILEGES ON DATABASE psidpdb TO psidpuser;
    \q
  4. Replace StrongPassword123 with your own secure password.

  5. Edit pg_hba.conf to allow remote access:

    $ sudo nano /etc/postgresql/*/main/pg_hba.conf
  6. Add:

    $ host psidpdb psidpuser 192.168.1.0/24 md5
  7. Allow external connections:

    $ sudo nano /etc/postgresql/*/main/postgresql.conf
  8. Find and update:

    $ listen_addresses = '*'
  9. Restart PostgreSQL:

    $ sudo systemctl restart postgresql
  10. Test from remote:

    $ psql -h 10.50.0.41 -U psidpuser -d psidpdb
    Allow port 5432 through firewall (if needed): ufw allow 5432

Configure PointsharpIdP on both instances

  • psidp-01: 10.50.0.31

  • psidp-02: 10.50.0.32

    1. Edit keycloak.conf:

      hostname=HOSTNAME
      hostname-strict=true
      db=postgres
      # PostgreSQL connection
      db-url=jdbc:postgresql://10.50.0.41:5432/psidpdb
      db-username=psidpuser
      db-password=StrongPassword123!
    2. Replace HOSTNAME with the actual hostname of the instances: psidp-01 and psidp-02

    3. Replace StrongPassword123 with your own secure password.

    4. Ensure both instances are using the same TLS certs and realm configuration.

    5. Start the IdP service:

      $ sudo systemctl start pointsharpidp
      $ sudo systemctl enable pointsharpidp

Test setup

  1. Check logs:

    $ journalctl -u pointsharpidp -f
  2. Ensure both nodes successfully connect to the PostgreSQL server and start without Liquibase schema errors.

  3. Done!

You now have a PostgreSQL database server with two Pointsharp IdP instances, using it in a shared high availability compatible setup.