1: caec9379055 = 1: caec9379055 oauth: Report cleanup errors as warnings on stderr 2: 6a2eda46927 ! 2: 7228af114ca libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock() @@ Commit message Reviewed-by: Zsolt Parragi Discussion: https://postgr.es/m/CAOYmi%2BmEU_q9sr1PMmE-4rLwFN%3DOjyndDwFZvpsMU3RNJLrM9g%40mail.gmail.com + ## doc/src/sgml/libpq.sgml ## +@@ doc/src/sgml/libpq.sgml: int PQisthreadsafe(); + Kerberos calls because Kerberos functions are not thread-safe. See + function PQregisterThreadLock in the + libpq source code for a way to do cooperative +- locking between libpq and your application. ++ locking between libpq and your application. (Note ++ that it is only safe to call PQregisterThreadLock when ++ there are no open connections.) Clients may retrieve the current locking ++ callback with PQgetThreadLock; if no custom callback ++ has been registered, a default is used. + + + + ## src/interfaces/libpq/exports.txt ## @@ src/interfaces/libpq/exports.txt: PQgetAuthDataHook 207 PQdefaultAuthDataHook 208 3: 12d4224bf61 ! 3: 751df22f99d libpq: Introduce PQAUTHDATA_OAUTH_BEARER_TOKEN_V2 @@ src/test/modules/oauth_validator/t/002_client.pl: if ($ENV{with_libcurl} ne 'yes $common_connstr = "$common_connstr connect_timeout=1"; test( @@ src/test/modules/oauth_validator/t/002_client.pl: foreach my $c (@cases) + "hook misbehavior: $c->{'flag'}", + flags => [ $c->{'flag'} ], expected_stderr => $c->{'expected_error'}); ++ ++ test( ++ "hook misbehavior: $c->{'flag'} (v1)", ++ flags => [ '-v1', $c->{'flag'} ], ++ expected_stderr => $c->{'expected_error'}); } +# v2 async flows should be able to set error messages, too. 4: 84d8dcd390e = 4: fb9915437da libpq-oauth: Use the PGoauthBearerRequestV2 API 5: e6b7735576b = 5: ed6e7268ec2 libpq-oauth: Never link against libpq's encoding functions -: ----------- > 6: e4b09853e3a WIP: test out poisoning 6: e4e5c5164b8 ! 7: 3d6d0901f7e WIP: Introduce third-party OAuth flow plugins? @@ src/interfaces/libpq-oauth/oauth-curl.h (deleted) ## src/interfaces/libpq/fe-auth-oauth.h ## @@ src/interfaces/libpq/fe-auth-oauth.h: typedef struct - void *async_ctx; + bool v1; bool builtin; - void *builtin_flow; + void *flow_module; @@ src/interfaces/libpq/fe-auth-oauth.c: extern int pg_start_oauthbearer(PGconn *co } @@ src/interfaces/libpq/fe-auth-oauth.c: setup_token_request(PGconn *conn, fe_oauth_state *state) - if (res == 0) - res = PQauthDataHook(PQAUTHDATA_OAUTH_BEARER_TOKEN, conn, &request); + poison_req_v2(&request, false); + } if (res == 0) - { - state->builtin = true; @@ src/interfaces/libpq/fe-auth-oauth.c: setup_token_request(PGconn *conn, fe_oauth - return true; fail: - if (request.v1.cleanup) + do_cleanup(state, &request); ## src/test/modules/oauth_validator/meson.build ## @@ src/test/modules/oauth_validator/meson.build: test_install_libs += magic_validator @@ src/test/modules/oauth_validator/t/002_client.pl: if ($ENV{with_libcurl} ne 'yes flags => ["--no-hook"], expected_stderr => qr/no OAuth flows are available \(try installing the libpq-oauth package\)/ +@@ src/test/modules/oauth_validator/t/002_client.pl: foreach my $c (@cases) + test( + "hook misbehavior: $c->{'flag'} (v1)", + flags => [ '-v1', $c->{'flag'} ], ++ hook_only => 1, # plugins can't use -v1 + expected_stderr => $c->{'expected_error'}); + } + @@ src/test/modules/oauth_validator/t/002_client.pl: test( expected_stderr => qr/user-defined OAuth flow failed: async error message/);