Re: [PoC] Federated Authn/z with OAUTHBEARER
mahendrakar s <mahendrakarforpg@gmail.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
meson: Fix install-quiet after clean
- a9ffb35274fb 18.0 landed
- 4ae03be54734 19 (unreleased) landed
-
oauth: Run Autoconf tests with correct compiler flags
- 3d23f68c5529 18.0 landed
- 990571a08b66 19 (unreleased) landed
-
Link libpq with libdl if the platform needs that.
- 4df477153a6b 19 (unreleased) landed
- 7bd752c1fb8e 18.0 landed
-
Doc: correct spelling of meson switch.
- 3faac9d14063 16.9 landed
- 766d2e673342 17.5 landed
- ac557793d478 18.0 landed
-
oauth: Correct SSL dependency for libpq-oauth.a
- 3db68212a393 18.0 landed
-
oauth: Fix Autoconf build on macOS
- 4ea1254f35b2 18.0 cited
-
oauth: Move the builtin flow into a separate module
- b0635bfda053 18.0 landed
-
Remove a stray "pgrminclude" annotation
- 764d501d24ba 18.0 cited
-
oauth: Simplify copy of PGoauthBearerRequest
- 1cf4c56480f8 18.0 landed
-
oauth: Improve validator docs on interruptibility
- 873c0fd67872 18.0 landed
-
oauth: Disallow synchronous DNS in libcurl
- d7e40845f923 18.0 landed
-
oauth: Fix postcondition for set_timer on macOS
- 434dbf6907ec 18.0 landed
-
oauth: Use IPv4-only issuer in oauth_validator tests
- 8d9d5843b55f 18.0 landed
-
Work around OAuth/EVFILT_TIMER quirk on NetBSD.
- c301a0a74a8a 18.0 landed
-
oauth: Fix incorrect const markers in struct
- 03366b61dfe5 18.0 landed
-
Add missing entry to oauth_validator test .gitignore
- 2c53dec7f440 18.0 landed
-
cirrus: Temporarily fix libcurl link error
- 9d9a71002a1c 18.0 landed
-
Add support for OAUTHBEARER SASL mechanism
- b3f0be788afc 18.0 landed
-
libpq: Handle asynchronous actions during SASL
- a99a32e43ed7 18.0 landed
-
require_auth: prepare for multiple SASL mechanisms
- f8d8581ed882 18.0 landed
-
Move PG_MAX_AUTH_TOKEN_LENGTH to libpq/auth.h
- e21d6f297158 18.0 landed
-
Make SASL max message length configurable
- 6d16f9debae0 18.0 landed
-
jsonapi: fully initialize dummy lexer
- 41b023946dfd 18.0 landed
-
common/jsonapi: support libpq as a client
- 0785d1b8b2fa 18.0 landed
-
Remove fe_memutils from libpgcommon_shlib
- f1976df5eaf2 18.0 landed
-
Revert ECPG's use of pnstrdup()
- f0096ef13be2 13.17 landed
- 3557185538fe 14.14 landed
- 2de129b356bf 15.9 landed
- ee2997c678d8 16.5 landed
- e9e05c655069 17.0 landed
- 5388216f6adc 18.0 landed
-
Explicitly require password for SCRAM exchange
- adcdb2c8dda4 17.0 landed
-
Refactor SASL exchange to return tri-state status
- 24178e235ea5 17.0 landed
Attachments
- v3-0001-libpq-add-OAUTHBEARER-SASL-mechanism-and-call-back-hooks.patch.gz (application/gzip) patch v3-0001
- v3-0002-backend-add-OAUTHBEARER-SASL-mechanishm.patch.gz (application/gzip) patch v3-0002
- v3-0004-common-jsonapi-support-FRONTEND-clients.patch.gz (application/gzip) patch v3-0004
- v3-0003-simple-oauth_provider-extension.patch.gz (application/gzip) patch v3-0003
Hi All, Changes added to Jacob's patch(v2) as per the discussion in the thread. The changes allow the customer to send the OAUTH BEARER token through psql connection string. Example: psql -U user@example.com -d 'dbname=postgres oauth_bearer_token=abc' To configure OAUTH, the pg_hba.conf line look like: local all all oauth provider=oauth_provider issuer="https://example.com" scope="openid email" We also added hook to libpq to pass on the metadata about the issuer. Thanks, Mahendrakar. On Sat, 17 Dec 2022 at 04:48, Jacob Champion <jchampion@timescale.com> wrote: > > On Mon, Dec 12, 2022 at 9:06 PM Andrey Chudnovsky > <achudnovskij@gmail.com> wrote: > > If your concern is extension not honoring the DBA configured values: > > Would a server-side logic to prefer HBA value over extension-provided > > resolve this concern? > > Yeah. It also seals the role of the extension here as "optional". > > > We are definitely biased towards the cloud deployment scenarios, where > > direct access to .hba files is usually not offered at all. > > Let's find the middle ground here. > > Sure. I don't want to make this difficult in cloud scenarios -- > obviously I'd like for Timescale Cloud to be able to make use of this > too. But if we make this easy for a lone DBA (who doesn't have any > institutional power with the providers) to use correctly and securely, > then it should follow that the providers who _do_ have power and > resources will have an easy time of it as well. The reverse isn't > necessarily true. So I'm definitely planning to focus on the DBA case > first. > > > A separate reason for creating this pre-authentication hook is further > > extensibility to support more metadata. > > Specifically when we add support for OAUTH flows to libpq, server-side > > extensions can help bridge the gap between the identity provider > > implementation and OAUTH/OIDC specs. > > For example, that could allow the Github extension to provide an OIDC > > discovery document. > > > > I definitely see identity providers as institutional actors here which > > can be given some power through the extension hooks to customize the > > behavior within the framework. > > We'll probably have to make some compromises in this area, but I think > they should be carefully considered exceptions and not a core feature > of the mechanism. The gaps you point out are just fragmentation, and > adding custom extensions to deal with it leads to further > fragmentation instead of providing pressure on providers to just > implement the specs. Worst case, we open up new exciting security > flaws, and then no one can analyze them independently because no one > other than the provider knows how the two sides work together anymore. > > Don't get me wrong; it would be naive to proceed as if the OAUTHBEARER > spec were perfect, because it's clearly not. But if we need to make > extensions to it, we can participate in IETF discussions and make our > case publicly for review, rather than enshrining MS/GitHub/Google/etc. > versions of the RFC and enabling that proliferation as a Postgres core > feature. > > > Obtaining a token is an asynchronous process with a human in the loop. > > Not sure if expecting a hook function to return a token synchronously > > is the best option here. > > Can that be an optional return value of the hook in cases when a token > > can be obtained synchronously? > > I don't think the hook is generally going to be able to return a token > synchronously, and I expect the final design to be async-first. As far > as I know, this will need to be solved for the builtin flows as well > (you don't want a synchronous HTTP call to block your PQconnectPoll > architecture), so the hook should be able to make use of whatever > solution we land on for that. > > This is hand-wavy, and I don't expect it to be easy to solve. I just > don't think we have to solve it twice. > > Have a good end to the year! > --Jacob