Skip to content

Add OAuth support #1162

Open
Open

Description

@dvarrazzo

PostgreSQL provides support for OAuth authentication.

There are a few libpq function helping to interact with OAuth parties (drafted in #1116), but on top of this low-level layer we will probably want to build something higher level, which must be designed.

Activity

  1. added
    enhancementNew feature or request
    funding requestedThe feature can be developed if there is financial support
    on Sep 7, 2025
  2. dutow commented on Jan 7, 2026

    @dutow

    Hello @dvarrazzo !

    Are you interested in help/contributions with this feature? If yes, do you have some ideas about the specific direction? The currently open pull request (#1190) seems quite minimal. I'm not a python expert, but I am familiar with PG + OIDC ( https://github.com/Percona-Lab/pg_oidc_validator/ ), and it would be great to get support for OIDC into psycopg.

  3. dvarrazzo commented on Jan 7, 2026

    @dvarrazzo
    MemberAuthor

    Hello @dutow

    This is a feature I want to work in the coming weeks, probably I will need to get in touch with other PostgreSQL devs to figure out better the features we want to implement.

    Nothing concrete right now but I can keep you informed.

  4. khushboovashi commented on Feb 5, 2026

    @khushboovashi

    Hi @dvarrazzo,

    If you had a chance to work on this, could you please share some insights into exactly what you plan to do?

    As per my understanding, if any client app (ex, pgAdmin) handles the Device Auth flow and passes the oauth_issuer and oauth_client_id connection parameters, the OAuth authentication should work. Please correct me if I am wrong, as I am currently working on supporting OAuth2 with PostgreSQL authentication in pgAdmin.

    Also, pgAdmin supports OAuth2 for user login, so I'm wondering whether that auth_token can be used directly and whether the device flow can be bypassed.

  5. dutow commented on Feb 5, 2026

    @dutow

    as I am currently working on supporting OAuth2 with PostgreSQL authentication in pgAdmin.

    That's great news, I asked my previous question with this end goal in mind

    Also, pgAdmin supports OAuth2 for user login, so I'm wondering whether that auth_token can be used directly and whether the device flow can be bypassed.

    This is why psychopg needs explicit support for OAuth, the hooks in libpq support this workflow, but they are currently not exposed to python. The issuer has to be the same as configured in pg_hba, and of course the server side oauth validator has to accept the token. This at minimum means that the token should contain the required oauth_scopes specified in pg_hba, and it should be a non expired oauth token, but validators can specify other more specific conditions.

  6. dutow commented on Feb 20, 2026

    @dutow

    @dvarrazzo @khushboovashi I started working on this, I have an experimental branch that works with both the python and C version, but for now I only created the PR about related test infrastructure changes / questions (#1264), and 2 more about small quality of life things I found/did while working on it.

  7. kfox1111 commented on Apr 17, 2026

    @kfox1111

    any movement on this? It would be great to have a release with this in it. especially since things like the trivy exploit have shown just how bad having static credentials can be.

  8. dvarrazzo commented on Apr 17, 2026

    @dvarrazzo
    MemberAuthor

    I have started working on this. There should be some news in the coming weeks.

  9. ivishalgandhi commented on Apr 27, 2026

    @ivishalgandhi

    +1

  10. kfox1111 commented on Jun 22, 2026

    @kfox1111

    Any updates on this?

  11. kfox1111 commented on Sep 2, 2026

    @kfox1111

    any updates? Would really really like to use this

  12. kfox1111 commented on Sep 8, 2026

    @kfox1111

    a static auth token would be problematic for me in some cases. It would be nice if it could be a lambda function so it can be dynamically fetched/generated.

  13. dvarrazzo commented on Sep 9, 2026

    @dvarrazzo
    MemberAuthor

    @UsmanGhias I have deleted your comments. Don't pust spam anymore or I will report you.

  14. deleted a comment from UsmanGhias on Sep 9, 2026
  15. dvarrazzo commented on Sep 9, 2026

    @dvarrazzo
    MemberAuthor

    @kfox1111 we are working on this feature. You should hear something about it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfunding requestedThe feature can be developed if there is financial support

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions