The terminal cursor blinked, waiting for your command. You type pgcli and wish it could log you in with Single Sign-On. No more typing passwords, no more juggling credentials, no more storing secrets in plain text.
Pgcli Single Sign-On (SSO) is not natively built into pgcli, but you can make it work. By combining secure token-based authentication with SSO identity providers, you can bring modern login flows right to your Postgres CLI. The result is a smooth, centralized authentication system that’s faster and safer than static credentials.
SSO with pgcli starts by moving away from direct username:password connections. Instead, you generate a short-lived database access token after authenticating through your SSO provider—Okta, Google Workspace, Azure AD, or any OIDC-compliant system. That token is then used in place of a password in pgcli <connection-string>. Tokens expire fast, reducing the attack surface.
You can automate the flow with a CLI tool that requests the SSO login, waits for the browser-based approval, and returns a fresh token. This token can be piped directly into pgcli, avoiding hardcoding secrets into .pgclirc or shell history. When paired with role-based access control from the IdP, you gain fine-grained permissions that sync instantly across all your tools.