|
PostgreSQL Source Code git master
|
#include "postgres_fe.h"#include <curl/curl.h>#include <math.h>#include <unistd.h>#include "common/jsonapi.h"#include "mb/pg_wchar.h"#include "oauth-curl.h"#include "fe-auth-oauth.h"#include "libpq-int.h"

Go to the source code of this file.
Data Structures | |
| struct | provider |
| struct | device_authz |
| struct | token_error |
| struct | token |
| struct | async_ctx |
| struct | json_field |
| struct | oauth_parse |
Enumerations | |
| enum | OAuthStep { OAUTH_STEP_INIT = 0 , OAUTH_STEP_DISCOVERY , OAUTH_STEP_DEVICE_AUTHORIZATION , OAUTH_STEP_TOKEN_REQUEST , OAUTH_STEP_WAIT_INTERVAL } |
| #define actx_error | ( | ACTX, | |
| FMT, | |||
| ... | |||
| ) | appendPQExpBuffer(&(ACTX)->errbuf, libpq_gettext(FMT), ##__VA_ARGS__) |
Definition at line 411 of file oauth-curl.c.
| #define actx_error_internal | ( | ACTX, | |
| FMT, | |||
| ... | |||
| ) | appendPQExpBuffer(&(ACTX)->errbuf, FMT, ##__VA_ARGS__) |
Definition at line 414 of file oauth-curl.c.
Definition at line 417 of file oauth-curl.c.
| #define CHECK_GETINFO | ( | ACTX, | |
| INFO, | |||
| OUT, | |||
| FAILACTION | |||
| ) |
Definition at line 447 of file oauth-curl.c.
| #define CHECK_MSETOPT | ( | ACTX, | |
| OPT, | |||
| VAL, | |||
| FAILACTION | |||
| ) |
Definition at line 425 of file oauth-curl.c.
| #define CHECK_SETOPT | ( | ACTX, | |
| OPT, | |||
| VAL, | |||
| FAILACTION | |||
| ) |
Definition at line 436 of file oauth-curl.c.
Definition at line 1961 of file oauth-curl.c.
| #define HTTPS_SCHEME "https://" |
Definition at line 2271 of file oauth-curl.c.
| #define MAX_OAUTH_NESTING_LEVEL 16 |
Definition at line 83 of file oauth-curl.c.
| #define MAX_OAUTH_RESPONSE_SIZE (256 * 1024) |
Definition at line 69 of file oauth-curl.c.
| #define OAUTH_GRANT_TYPE_DEVICE_CODE "urn:ietf:params:oauth:grant-type:device_code" |
Definition at line 2272 of file oauth-curl.c.
| #define oauth_parse_set_error | ( | ctx, | |
| fmt, | |||
| ... | |||
| ) | appendPQExpBuffer((ctx)->errbuf, libpq_gettext(fmt), ##__VA_ARGS__) |
Definition at line 501 of file oauth-curl.c.
| #define oauth_parse_set_error_internal | ( | ctx, | |
| fmt, | |||
| ... | |||
| ) | appendPQExpBuffer((ctx)->errbuf, fmt, ##__VA_ARGS__) |
Definition at line 504 of file oauth-curl.c.
| #define PG_CURL_IGNORE_DEPRECATION | ( | x | ) | CURL_IGNORE_DEPRECATION(x;) |
Definition at line 1968 of file oauth-curl.c.
Definition at line 489 of file oauth-curl.c.
Definition at line 488 of file oauth-curl.c.
| Enumerator | |
|---|---|
| OAUTH_STEP_INIT | |
| OAUTH_STEP_DISCOVERY | |
| OAUTH_STEP_DEVICE_AUTHORIZATION | |
| OAUTH_STEP_TOKEN_REQUEST | |
| OAUTH_STEP_WAIT_INTERVAL | |
Definition at line 200 of file oauth-curl.c.
|
static |
Definition at line 2339 of file oauth-curl.c.
References actx_error, build_urlencoded(), CHECK_SETOPT, cleanup(), fb(), free, password, success, urlencode(), and username.
Referenced by start_device_authz(), and start_token_request().
|
static |
Definition at line 371 of file oauth-curl.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), PQExpBufferData::data, async_ctx::errbuf, fb(), PQExpBufferData::len, libpq_gettext, PQExpBufferDataBroken, and resetPQExpBuffer().
Referenced by pg_fe_run_oauth_flow_impl(), and pg_start_oauthbearer().
Definition at line 1880 of file oauth-curl.c.
References actx_error, appendBinaryPQExpBuffer(), buf, fb(), len, MAX_OAUTH_RESPONSE_SIZE, and PQExpBufferBroken.
Referenced by restore_one_database(), RestoreArchive(), SetOutput(), and start_request().
|
static |
Definition at line 2074 of file oauth-curl.c.
References appendBinaryPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), buf, fb(), and termPQExpBuffer().
Referenced by build_urlencoded(), and urlencode().
Definition at line 2132 of file oauth-curl.c.
References append_urlencoded(), appendPQExpBufferChar(), buf, and value.
Referenced by add_client_identification(), start_device_authz(), and start_token_request().
Definition at line 804 of file oauth-curl.c.
References actx_error, Assert, CHECK_GETINFO, fb(), i, pg_strncasecmp(), and type.
Referenced by parse_oauth_json().
Definition at line 2280 of file oauth-curl.c.
References actx_error, Assert, provider::device_authorization_endpoint, fb(), HTTPS_SCHEME, provider::issuer, pg_strncasecmp(), and provider::token_endpoint.
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 2235 of file oauth-curl.c.
References actx_error, Assert, fb(), and provider::issuer.
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 1441 of file oauth-curl.c.
References actx_error_internal, and fb().
Referenced by pg_fe_run_oauth_flow_impl().
|
static |
Definition at line 1664 of file oauth-curl.c.
References appendPQExpBuffer(), appendPQExpBufferChar(), buf, data, fb(), fprintf, i, initPQExpBuffer(), termPQExpBuffer(), and type.
Referenced by setup_curl_handles().
Definition at line 1632 of file oauth-curl.c.
References fb(), set_timer(), and timer_expired().
Referenced by pg_fe_run_oauth_flow_impl().
|
static |
Definition at line 1975 of file oauth-curl.c.
References actx_error, actx_error_str, err(), fb(), PG_CURL_IGNORE_DEPRECATION, PGRES_POLLING_FAILED, PGRES_POLLING_OK, and PGRES_POLLING_READING.
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 2453 of file oauth-curl.c.
References actx_error, CHECK_GETINFO, err(), fb(), free_token_error(), libpq_gettext, parse_device_authz(), parse_token_error(), and record_token_error().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 2170 of file oauth-curl.c.
References actx_error, CHECK_GETINFO, fb(), libpq_gettext, and parse_provider().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 2541 of file oauth-curl.c.
References actx_error, CHECK_GETINFO, fb(), libpq_gettext, parse_access_token(), and parse_token_error().
Referenced by handle_token_response().
Definition at line 284 of file oauth-curl.c.
References close, err(), fb(), fprintf, free, free_device_authz(), free_provider(), libpq_gettext, PGINVALID_SOCKET, and termPQExpBuffer().
Referenced by pg_fe_cleanup_oauth_flow().
|
static |
Definition at line 137 of file oauth-curl.c.
References device_authz::device_code, device_authz::expires_in_str, free, device_authz::interval_str, device_authz::user_code, device_authz::verification_uri, and device_authz::verification_uri_complete.
Referenced by free_async_ctx().
Definition at line 109 of file oauth-curl.c.
References provider::device_authorization_endpoint, fb(), free, provider::grant_types_supported, provider::issuer, and provider::token_endpoint.
Referenced by free_async_ctx().
Definition at line 188 of file oauth-curl.c.
References fb(), free, and free_token_error().
Referenced by handle_token_response().
|
static |
Definition at line 162 of file oauth-curl.c.
Referenced by finish_device_authz(), and free_token().
Definition at line 2588 of file oauth-curl.c.
References token::access_token, actx_error, Assert, err(), fb(), finish_token_request(), free_token(), record_token_error(), and success.
Referenced by pg_fe_run_oauth_flow_impl().
|
static |
Definition at line 2694 of file oauth-curl.c.
References fb(), libpq_gettext, PG_BOOL_NO, PG_BOOL_UNKNOWN, PG_BOOL_YES, pglock_thread, and pgunlock_thread.
Referenced by pg_start_oauthbearer().
|
static |
Definition at line 676 of file oauth-curl.c.
References oauth_parse::active, Assert, fb(), JSON_SEM_ACTION_FAILED, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, json_field::name, oauth_parse::nested, oauth_parse_set_error_internal, and json_field::type.
Referenced by parse_oauth_json().
|
static |
Definition at line 644 of file oauth-curl.c.
References oauth_parse::active, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, MAX_OAUTH_NESTING_LEVEL, oauth_parse::nested, oauth_parse_set_error, report_type_mismatch(), and json_field::type.
Referenced by parse_oauth_json().
|
static |
Definition at line 621 of file oauth-curl.c.
References oauth_parse::active, Assert, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, json_field::name, oauth_parse::nested, and oauth_parse_set_error_internal.
Referenced by parse_oauth_json().
|
static |
Definition at line 566 of file oauth-curl.c.
References oauth_parse::active, json_field::array, Assert, fb(), oauth_parse::fields, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, name, json_field::name, oauth_parse::nested, oauth_parse_set_error, oauth_parse_set_error_internal, json_field::scalar, and json_field::type.
Referenced by parse_oauth_json().
|
static |
Definition at line 541 of file oauth-curl.c.
References oauth_parse::active, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, MAX_OAUTH_NESTING_LEVEL, oauth_parse::nested, oauth_parse_set_error, and report_type_mismatch().
Referenced by parse_oauth_json().
|
static |
Definition at line 704 of file oauth-curl.c.
References oauth_parse::active, json_field::array, Assert, fb(), JSON_OUT_OF_MEMORY, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, JSON_TOKEN_STRING, json_field::name, oauth_parse::nested, oauth_parse_set_error, oauth_parse_set_error_internal, report_type_mismatch(), json_field::scalar, type, and json_field::type.
Referenced by parse_oauth_json().
Definition at line 1175 of file oauth-curl.c.
References fb(), JSON_TOKEN_STRING, parse_oauth_json(), and PG_OAUTH_REQUIRED.
Referenced by finish_token_request().
|
static |
Definition at line 1061 of file oauth-curl.c.
References Assert, device_authz::device_code, device_authz::expires_in, device_authz::expires_in_str, fb(), device_authz::interval, device_authz::interval_str, JSON_TOKEN_NUMBER, JSON_TOKEN_STRING, parse_expires_in(), parse_interval(), parse_oauth_json(), PG_OAUTH_OPTIONAL, PG_OAUTH_REQUIRED, device_authz::user_code, device_authz::verification_uri, and device_authz::verification_uri_complete.
Referenced by finish_device_authz().
Definition at line 1042 of file oauth-curl.c.
References fb(), and parse_json_number().
Referenced by parse_device_authz().
Definition at line 1016 of file oauth-curl.c.
References fb(), and parse_json_number().
Referenced by parse_device_authz().
Definition at line 981 of file oauth-curl.c.
Referenced by parse_expires_in(), and parse_interval().
|
static |
Definition at line 863 of file oauth-curl.c.
References actx_error, actx_error_str, json_field::array, JsonSemAction::array_end, JsonSemAction::array_start, check_content_type(), cleanup(), err(), oauth_parse::errbuf, fb(), oauth_parse::fields, freeJsonLexContext(), json_errdetail(), JSON_SEM_ACTION_FAILED, JSON_SUCCESS, makeJsonLexContextCstringLen(), json_field::name, oauth_json_array_end(), oauth_json_array_start(), oauth_json_object_end(), oauth_json_object_field_start(), oauth_json_object_start(), oauth_json_scalar(), JsonSemAction::object_end, JsonSemAction::object_field_start, JsonSemAction::object_start, pg_encoding_verifymbstr(), pg_parse_json(), PG_UTF8, json_field::required, JsonSemAction::scalar, json_field::scalar, sem, JsonSemAction::semstate, setJsonLexContextOwnsTokens(), and success.
Referenced by parse_access_token(), parse_device_authz(), parse_provider(), and parse_token_error().
Definition at line 950 of file oauth-curl.c.
References provider::device_authorization_endpoint, fb(), provider::grant_types_supported, provider::issuer, JSON_TOKEN_ARRAY_START, JSON_TOKEN_STRING, parse_oauth_json(), PG_OAUTH_OPTIONAL, PG_OAUTH_REQUIRED, and provider::token_endpoint.
Referenced by finish_discovery().
|
static |
Definition at line 1115 of file oauth-curl.c.
References err(), fb(), JSON_TOKEN_STRING, libpq_gettext, parse_oauth_json(), PG_OAUTH_OPTIONAL, and PG_OAUTH_REQUIRED.
Referenced by finish_device_authz(), and finish_token_request().
|
static |
Definition at line 347 of file oauth-curl.c.
References Assert, explicit_bzero(), fb(), free, and free_async_ctx().
Referenced by pg_start_oauthbearer().
|
static |
Definition at line 3000 of file oauth-curl.c.
References conn, fb(), fprintf, pg_fe_run_oauth_flow_impl(), PGRES_POLLING_FAILED, PGRES_POLLING_OK, pq_block_sigpipe(), and pq_reset_sigpipe().
Referenced by pg_start_oauthbearer().
|
static |
Definition at line 2801 of file oauth-curl.c.
References append_actx_error(), check_for_device_flow(), check_issuer(), comb_multiplexer(), conn, drain_timer_events(), drive_request(), fb(), finish_device_authz(), finish_discovery(), handle_token_response(), libpq_gettext, async_ctx::mux, OAUTH_STEP_DEVICE_AUTHORIZATION, OAUTH_STEP_DISCOVERY, OAUTH_STEP_INIT, OAUTH_STEP_TOKEN_REQUEST, OAUTH_STEP_WAIT_INTERVAL, PGRES_POLLING_FAILED, PGRES_POLLING_OK, PGRES_POLLING_READING, prompt_user(), set_timer(), start_device_authz(), start_discovery(), and start_token_request().
Referenced by pg_fe_run_oauth_flow().
| int pg_start_oauthbearer | ( | PGconn * | conn, |
| PGoauthBearerRequestV2 * | request | ||
| ) |
Definition at line 3067 of file oauth-curl.c.
References append_actx_error(), Assert, calloc, conn, fb(), initialize_curl(), initPQExpBuffer(), _PQconninfoOption::keyword, libpq_gettext, oauth_unsafe_debugging_enabled(), pg_fe_cleanup_oauth_flow(), pg_fe_run_oauth_flow(), PGINVALID_SOCKET, PQconninfo(), PQconninfoFree(), setup_curl_handles(), and setup_multiplexer().
Definition at line 2649 of file oauth-curl.c.
References actx_error, conn, fb(), fprintf, libpq_gettext, PQAUTHDATA_PROMPT_OAUTH_DEVICE, PQgetAuthDataHook(), and _PGpromptOAuthDevice::verification_uri.
Referenced by pg_fe_run_oauth_flow_impl().
|
static |
Definition at line 1143 of file oauth-curl.c.
References actx_error, actx_error_str, appendPQExpBuffer(), CHECK_GETINFO, err(), fb(), and gettext_noop.
Referenced by finish_device_authz(), and handle_token_response().
|
static |
Definition at line 1275 of file oauth-curl.c.
References actx_error_internal, Assert, fb(), i, lengthof, and socket.
Referenced by setup_curl_handles().
Definition at line 1610 of file oauth-curl.c.
References fb(), and set_timer().
Referenced by setup_curl_handles().
|
static |
Definition at line 508 of file oauth-curl.c.
References oauth_parse::active, Assert, fb(), gettext_noop, JSON_TOKEN_ARRAY_START, JSON_TOKEN_NUMBER, JSON_TOKEN_STRING, json_field::name, oauth_parse_set_error, and json_field::type.
Referenced by oauth_json_array_start(), oauth_json_object_start(), and oauth_json_scalar().
Definition at line 1489 of file oauth-curl.c.
References actx_error_internal, and fb().
Referenced by drain_timer_events(), pg_fe_run_oauth_flow_impl(), and register_timer().
Definition at line 1747 of file oauth-curl.c.
References actx_error, CHECK_MSETOPT, CHECK_SETOPT, debug_callback(), fb(), register_socket(), and register_timer().
Referenced by pg_start_oauthbearer().
Definition at line 1217 of file oauth-curl.c.
References actx_error_internal, and fb().
Referenced by pg_start_oauthbearer().
Definition at line 2423 of file oauth-curl.c.
References actx_error, add_client_identification(), Assert, build_urlencoded(), CHECK_SETOPT, conn, fb(), PQExpBufferBroken, resetPQExpBuffer(), and start_request().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 2161 of file oauth-curl.c.
References CHECK_SETOPT, async_ctx::discovery_uri, fb(), and start_request().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 1920 of file oauth-curl.c.
References actx_error, append_data(), CHECK_SETOPT, err(), fb(), and resetPQExpBuffer().
Referenced by start_device_authz(), start_discovery(), and start_token_request().
Definition at line 2510 of file oauth-curl.c.
References actx_error, add_client_identification(), Assert, build_urlencoded(), CHECK_SETOPT, conn, fb(), OAUTH_GRANT_TYPE_DEVICE_CODE, PQExpBufferBroken, resetPQExpBuffer(), and start_request().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 1586 of file oauth-curl.c.
References actx_error, fb(), and PQsocketPoll().
Referenced by drain_timer_events().
Definition at line 2117 of file oauth-curl.c.
References append_urlencoded(), buf, fb(), initPQExpBuffer(), and PQExpBufferDataBroken.
Referenced by add_client_identification().