Skip to content

triauth for pgAdminOIDC

Let your database team open pgAdmin with one approval on their own device, and no pgAdmin passwords.

  • Databases
  • Open source
Sign-in through
OpenID Connect bridge
Available in
pgAdmin 4 in server mode
Set up in
config_local.py

About pgAdmin

pgAdmin is the administration tool for PostgreSQL databases: it browses schemas, runs queries, shows dashboards, and manages backups. Teams run it in server mode on a shared host, so several people use one installation with their own logins.

Connect pgAdmin to triauth

pgAdmin signs people in through the triauth OpenID Connect bridge. Once connected, the login page shows Login with and your domain's name. People on your team click it, type their username, and approve on their own device. Nobody keeps a pgAdmin password, and when someone leaves, removing their identity records at your domain ends their access to pgAdmin as well.

How it works

  1. Open oidc.triauth.org and enter your domain. Paste pgAdmin's redirect address, https://pgadmin.example.com/oauth2/authorize with your own pgAdmin address in place of pgadmin.example.com, and click Connect app. The bridge gives you a client ID and a client secret.

  2. Add the settings below to pgAdmin's config_local.py and restart it. Replace example.com with your domain and the two placeholders with the client ID and the client secret from the bridge.

    python
    AUTHENTICATION_SOURCES = ['oauth2', 'internal']
    OAUTH2_AUTO_CREATE_USER = True
    OAUTH2_CONFIG = [{
        'OAUTH2_NAME': 'triauth',
        'OAUTH2_DISPLAY_NAME': 'example.com',
        'OAUTH2_CLIENT_ID': '<client ID from the bridge>',
        'OAUTH2_CLIENT_SECRET': '<client secret from the bridge>',
        'OAUTH2_SERVER_METADATA_URL': 'https://oidc.triauth.org/example.com/.well-known/openid-configuration',
        'OAUTH2_SCOPE': 'openid email profile',
        'OAUTH2_ICON': 'fa-key',
        'OAUTH2_BUTTON_COLOR': '#3253a8',
    }]
  3. Open pgAdmin's login page and click Login with example.com.

Checkpoint

pgAdmin's login page shows Login with example.com next to the password form. Choosing it opens a page from the bridge that asks for the username, and the person's authenticator asks them to approve.

Good to know

  • Everyone with an identity at your domain gets a pgAdmin user the first time they sign in, with their identifier as user name. To let only one team in, limit the app to a group when you connect it, or list the allowed groups in OAUTH2_ADDITIONAL_CLAIMS with the groups scope added.
  • Administrator rights are given per user in pgAdmin. Create an administrator through the bridge before you turn the internal login off.
  • The desktop version of pgAdmin has no sign-in of its own, so this applies to the shared server.

For the person who connects the app

SettingValue
Redirect addresshttps://<your-pgadmin>/oauth2/authorize, built from pgAdmin's public address, so a reverse proxy must pass the forwarded headers
Where in pgAdminconfig_local.py or config_system.py, or PGADMIN_CONFIG_OAUTH2_CONFIG in a container
Metadata URLthe bridge's discovery document. pgAdmin requires it whenever openid is in the scope and reads every address from it
Without a secretif you ticked This app can't keep a secret on the bridge, set OAUTH2_CHALLENGE_METHOD: 'S256' and OAUTH2_RESPONSE_TYPE: 'code'
Sign-outleave OAUTH2_LOGOUT_URL unset, since the bridge has no sign-out endpoint
pgAdmin's login page with a Login with button for an OAuth2 provider
pgAdmin's login page with a provider button. Source: the pgAdmin documentation, PostgreSQL licence.

pgAdmin keeps the client secret, so leave This app can't keep a secret unticked when you connect it on the bridge. pgAdmin's OAuth2 guide explains every key.

Next steps

All logos and trademarks belong to their respective owners and do not imply affiliation or endorsement of the organization or product by triauth, nor vice versa. The content provided on this page may include information from third-party sources. We do not assume any responsibility for the completeness, correctness, or applicability of the information. You should independently verify any details before relying on them.