|
PostgreSQL Source Code git master
|
#include "postgres_fe.h"#include <curl/curl.h>#include <math.h>#include <unistd.h>#include "common/jsonapi.h"#include "fe-auth-oauth.h"#include "mb/pg_wchar.h"#include "oauth-curl.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 375 of file oauth-curl.c.
| #define actx_error_internal | ( | ACTX, | |
| FMT, | |||
| ... | |||
| ) | appendPQExpBuffer(&(ACTX)->errbuf, FMT, ##__VA_ARGS__) |
Definition at line 378 of file oauth-curl.c.
Definition at line 381 of file oauth-curl.c.
| #define CHECK_GETINFO | ( | ACTX, | |
| INFO, | |||
| OUT, | |||
| FAILACTION | |||
| ) |
Definition at line 411 of file oauth-curl.c.
| #define CHECK_MSETOPT | ( | ACTX, | |
| OPT, | |||
| VAL, | |||
| FAILACTION | |||
| ) |
Definition at line 389 of file oauth-curl.c.
| #define CHECK_SETOPT | ( | ACTX, | |
| OPT, | |||
| VAL, | |||
| FAILACTION | |||
| ) |
Definition at line 400 of file oauth-curl.c.
Definition at line 53 of file oauth-curl.c.
Definition at line 54 of file oauth-curl.c.
Definition at line 55 of file oauth-curl.c.
Definition at line 56 of file oauth-curl.c.
Definition at line 57 of file oauth-curl.c.
Definition at line 58 of file oauth-curl.c.
Definition at line 59 of file oauth-curl.c.
Definition at line 1925 of file oauth-curl.c.
| #define HTTPS_SCHEME "https://" |
Definition at line 2235 of file oauth-curl.c.
| #define MAX_OAUTH_NESTING_LEVEL 16 |
Definition at line 97 of file oauth-curl.c.
| #define MAX_OAUTH_RESPONSE_SIZE (256 * 1024) |
Definition at line 83 of file oauth-curl.c.
| #define OAUTH_GRANT_TYPE_DEVICE_CODE "urn:ietf:params:oauth:grant-type:device_code" |
Definition at line 2236 of file oauth-curl.c.
| #define oauth_parse_set_error | ( | ctx, | |
| fmt, | |||
| ... | |||
| ) | appendPQExpBuffer((ctx)->errbuf, libpq_gettext(fmt), ##__VA_ARGS__) |
Definition at line 465 of file oauth-curl.c.
| #define oauth_parse_set_error_internal | ( | ctx, | |
| fmt, | |||
| ... | |||
| ) | appendPQExpBuffer((ctx)->errbuf, fmt, ##__VA_ARGS__) |
Definition at line 468 of file oauth-curl.c.
| #define PG_CURL_IGNORE_DEPRECATION | ( | x | ) | CURL_IGNORE_DEPRECATION(x;) |
Definition at line 1932 of file oauth-curl.c.
Definition at line 453 of file oauth-curl.c.
Definition at line 452 of file oauth-curl.c.
Definition at line 61 of file oauth-curl.c.
Definition at line 62 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 214 of file oauth-curl.c.
|
static |
Definition at line 2303 of file oauth-curl.c.
References actx_error, build_urlencoded(), CHECK_SETOPT, cleanup(), conn, conn_oauth_client_id, conn_oauth_client_secret, fb(), free, password, success, urlencode(), and username.
Referenced by start_device_authz(), and start_token_request().
Definition at line 1844 of file oauth-curl.c.
References actx_error, appendBinaryPQExpBuffer(), buf, fb(), len, MAX_OAUTH_RESPONSE_SIZE, and PQExpBufferBroken.
Referenced by start_request().
|
static |
Definition at line 2038 of file oauth-curl.c.
References appendBinaryPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), buf, fb(), and termPQExpBuffer().
Referenced by build_urlencoded(), and urlencode().
Definition at line 2096 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 768 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 2244 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 2199 of file oauth-curl.c.
References actx_error, Assert, conn, conn_oauth_issuer_id, fb(), and provider::issuer.
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 1405 of file oauth-curl.c.
References actx_error_internal, and fb().
Referenced by pg_fe_run_oauth_flow_impl().
|
static |
Definition at line 1628 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 1596 of file oauth-curl.c.
References fb(), set_timer(), and timer_expired().
Referenced by pg_fe_run_oauth_flow_impl().
|
static |
Definition at line 1939 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 2418 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 2134 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 2507 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 289 of file oauth-curl.c.
References close, conn, err(), fb(), free, free_device_authz(), free_provider(), libpq_append_conn_error(), PGINVALID_SOCKET, and termPQExpBuffer().
Referenced by pg_fe_cleanup_oauth_flow().
|
static |
Definition at line 151 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 123 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 202 of file oauth-curl.c.
References fb(), free, and free_token_error().
Referenced by handle_token_response().
|
static |
Definition at line 176 of file oauth-curl.c.
Referenced by finish_device_authz(), and free_token().
Definition at line 2554 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().
Definition at line 2660 of file oauth-curl.c.
References conn, fb(), libpq_append_conn_error(), PG_BOOL_NO, PG_BOOL_UNKNOWN, PG_BOOL_YES, pglock_thread, and pgunlock_thread.
Referenced by pg_fe_run_oauth_flow_impl().
|
static |
Definition at line 640 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 608 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 585 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 530 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 505 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 668 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 1139 of file oauth-curl.c.
References fb(), JSON_TOKEN_STRING, parse_oauth_json(), and PG_OAUTH_REQUIRED.
Referenced by finish_token_request().
Definition at line 1025 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 1006 of file oauth-curl.c.
References fb(), and parse_json_number().
Referenced by parse_device_authz().
Definition at line 980 of file oauth-curl.c.
References fb(), and parse_json_number().
Referenced by parse_device_authz().
Definition at line 945 of file oauth-curl.c.
Referenced by parse_expires_in(), and parse_interval().
Definition at line 827 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 914 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().
Definition at line 1079 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().
Definition at line 356 of file oauth-curl.c.
References conn, conn_sasl_state, fb(), free_async_ctx(), PGINVALID_SOCKET, and set_conn_altsock.
| PostgresPollingStatusType pg_fe_run_oauth_flow | ( | PGconn * | conn | ) |
Definition at line 3033 of file oauth-curl.c.
References Assert, conn, conn_sasl_state, fb(), fprintf, pg_fe_run_oauth_flow_impl(), PGRES_POLLING_FAILED, PGRES_POLLING_OK, pq_block_sigpipe(), and pq_reset_sigpipe().
|
static |
Definition at line 2769 of file oauth-curl.c.
References appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), calloc, check_for_device_flow(), check_issuer(), comb_multiplexer(), conn, conn_errorMessage, conn_oauth_discovery_uri, conn_sasl_state, PQExpBufferData::data, drain_timer_events(), drive_request(), async_ctx::errbuf, fb(), finish_device_authz(), finish_discovery(), handle_token_response(), initialize_curl(), initPQExpBuffer(), PQExpBufferData::len, libpq_append_conn_error(), libpq_gettext, OAUTH_STEP_DEVICE_AUTHORIZATION, OAUTH_STEP_DISCOVERY, OAUTH_STEP_INIT, OAUTH_STEP_TOKEN_REQUEST, OAUTH_STEP_WAIT_INTERVAL, oauth_unsafe_debugging_enabled(), PGINVALID_SOCKET, PGRES_POLLING_FAILED, PGRES_POLLING_OK, PGRES_POLLING_READING, PQExpBufferDataBroken, prompt_user(), set_conn_altsock, set_conn_oauth_token, set_timer(), setup_curl_handles(), setup_multiplexer(), start_device_authz(), start_discovery(), and start_token_request().
Referenced by pg_fe_run_oauth_flow().
Definition at line 2615 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().
Definition at line 1107 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 1239 of file oauth-curl.c.
References actx_error_internal, Assert, fb(), i, lengthof, and socket.
Referenced by setup_curl_handles().
Definition at line 1574 of file oauth-curl.c.
References fb(), and set_timer().
Referenced by setup_curl_handles().
|
static |
Definition at line 472 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 1453 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 1711 of file oauth-curl.c.
References actx_error, CHECK_MSETOPT, CHECK_SETOPT, debug_callback(), fb(), register_socket(), and register_timer().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 1181 of file oauth-curl.c.
References actx_error_internal, and fb().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 2387 of file oauth-curl.c.
References actx_error, add_client_identification(), Assert, build_urlencoded(), CHECK_SETOPT, conn, conn_oauth_client_id, conn_oauth_scope, fb(), PQExpBufferBroken, resetPQExpBuffer(), and start_request().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 2125 of file oauth-curl.c.
References CHECK_SETOPT, fb(), and start_request().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 1884 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 2475 of file oauth-curl.c.
References actx_error, add_client_identification(), Assert, build_urlencoded(), CHECK_SETOPT, conn, conn_oauth_client_id, fb(), OAUTH_GRANT_TYPE_DEVICE_CODE, PQExpBufferBroken, resetPQExpBuffer(), and start_request().
Referenced by pg_fe_run_oauth_flow_impl().
Definition at line 1550 of file oauth-curl.c.
References actx_error, fb(), and PQsocketPoll().
Referenced by drain_timer_events().
Definition at line 2081 of file oauth-curl.c.
References append_urlencoded(), buf, fb(), initPQExpBuffer(), and PQExpBufferDataBroken.
Referenced by add_client_identification().