|
PostgreSQL Source Code git master
|
#include "postgres_fe.h"#include "common/base64.h"#include "common/hmac.h"#include "common/jsonapi.h"#include "common/oauth-common.h"#include "fe-auth.h"#include "fe-auth-oauth.h"#include "mb/pg_wchar.h"#include "oauth-debug.h"#include "pg_config_paths.h"#include "utils/memdebug.h"
Go to the source code of this file.
Data Structures | |
| struct | json_ctx |
Macros | |
| #define | kvsep "\x01" |
| #define | ERROR_STATUS_FIELD "status" |
| #define | ERROR_SCOPE_FIELD "scope" |
| #define | ERROR_OPENID_CONFIGURATION_FIELD "openid-configuration" |
| #define | MAX_SASL_NESTING_LEVEL 8 |
| #define | oauth_json_has_error(ctx) (PQExpBufferDataBroken((ctx)->errbuf) || (ctx)->errmsg) |
| #define | oauth_json_set_error(ctx, fmt, ...) |
| #define | oauth_json_set_error_internal(ctx, ...) |
| #define | HTTPS_SCHEME "https://" |
| #define | HTTP_SCHEME "http://" |
| #define | WK_PREFIX "/.well-known/" |
| #define | OPENID_WK_SUFFIX "openid-configuration" |
| #define | OAUTH_WK_SUFFIX "oauth-authorization-server" |
| #define | MASK_BITS ((uintptr_t) 0x55aa55aa55aa55aa) |
| #define | POISON_MASK(ptr) ((void *) (((uintptr_t) ptr) ^ MASK_BITS)) |
Variables | |
| const pg_fe_sasl_mech | pg_oauth_mech |
| #define ERROR_OPENID_CONFIGURATION_FIELD "openid-configuration" |
Definition at line 165 of file fe-auth-oauth.c.
| #define ERROR_SCOPE_FIELD "scope" |
Definition at line 164 of file fe-auth-oauth.c.
| #define ERROR_STATUS_FIELD "status" |
Definition at line 163 of file fe-auth-oauth.c.
| #define HTTP_SCHEME "http://" |
Definition at line 361 of file fe-auth-oauth.c.
| #define HTTPS_SCHEME "https://" |
Definition at line 360 of file fe-auth-oauth.c.
| #define kvsep "\x01" |
Definition at line 101 of file fe-auth-oauth.c.
Definition at line 1455 of file fe-auth-oauth.c.
| #define MAX_SASL_NESTING_LEVEL 8 |
Definition at line 173 of file fe-auth-oauth.c.
| #define oauth_json_has_error | ( | ctx | ) | (PQExpBufferDataBroken((ctx)->errbuf) || (ctx)->errmsg) |
Definition at line 190 of file fe-auth-oauth.c.
| #define oauth_json_set_error_internal | ( | ctx, | |
| ... | |||
| ) |
Definition at line 200 of file fe-auth-oauth.c.
Definition at line 366 of file fe-auth-oauth.c.
| #define OPENID_WK_SUFFIX "openid-configuration" |
Definition at line 365 of file fe-auth-oauth.c.
Definition at line 1456 of file fe-auth-oauth.c.
Definition at line 364 of file fe-auth-oauth.c.
Definition at line 805 of file fe-auth-oauth.c.
References pg_conn::altsock, Assert, conn, do_cleanup(), fb(), free, PGINVALID_SOCKET, and pg_conn::sasl_state.
Referenced by setup_token_request().
Definition at line 113 of file fe-auth-oauth.c.
References appendPQExpBuffer(), Assert, buf, conn, fb(), initPQExpBuffer(), kvsep, libpq_append_conn_error(), pg_conn::oauth_token, PQExpBufferDataBroken, and termPQExpBuffer().
Referenced by oauth_exchange().
|
static |
Definition at line 1518 of file fe-auth-oauth.c.
References pg_conn::altsock, Assert, conn, fb(), and poison_req_v2().
Referenced by run_oauth_flow().
|
static |
Definition at line 1543 of file fe-auth-oauth.c.
References fb(), and poison_req_v2().
Referenced by cleanup_oauth_flow(), and setup_token_request().
Definition at line 520 of file fe-auth-oauth.c.
References JsonSemAction::array_end, JsonSemAction::array_start, Assert, cleanup(), conn, json_ctx::discovery_uri, err(), json_ctx::errbuf, json_ctx::errmsg, errmsg, fb(), free, freeJsonLexContext(), initPQExpBuffer(), issuer_from_well_known_uri(), json_errdetail(), JSON_SEM_ACTION_FAILED, JSON_SUCCESS, libpq_append_conn_error(), libpq_gettext, makeJsonLexContextCstringLen(), pg_conn::oauth_discovery_uri, pg_conn::oauth_issuer_id, oauth_json_array_end(), oauth_json_array_start(), oauth_json_has_error, oauth_json_object_end(), oauth_json_object_field_start(), oauth_json_object_start(), oauth_json_scalar(), pg_conn::oauth_scope, JsonSemAction::object_end, JsonSemAction::object_field_start, JsonSemAction::object_start, pg_encoding_verifymbstr(), pg_parse_json(), PG_UTF8, PQExpBufferDataBroken, JsonSemAction::scalar, json_ctx::scope, sem, JsonSemAction::semstate, setJsonLexContextOwnsTokens(), json_ctx::status, success, and termPQExpBuffer().
Referenced by oauth_exchange().
Definition at line 373 of file fe-auth-oauth.c.
References Assert, conn, fb(), HTTP_SCHEME, HTTPS_SCHEME, libpq_append_conn_error(), oauth_parse_debug_flags(), OAUTH_WK_SUFFIX, OAUTHDEBUG_UNSAFE_HTTP, OPENID_WK_SUFFIX, pg_strncasecmp(), and WK_PREFIX.
Referenced by handle_oauth_sasl_error(), and setup_oauth_parameters().
Definition at line 1420 of file fe-auth-oauth.c.
|
static |
Definition at line 1195 of file fe-auth-oauth.c.
References Assert, pg_conn::async_auth, pg_conn::client_finished_auth, client_initial_response(), conn, fb(), FE_OAUTH_BEARER_SENT, FE_OAUTH_INIT, FE_OAUTH_REQUESTING_TOKEN, FE_OAUTH_SERVER_ERROR, handle_oauth_sasl_error(), input, kvsep, libpq_append_conn_error(), pg_conn::oauth_discovery_uri, pg_conn::oauth_token, pg_conn::oauth_want_retry, output, SASL_ASYNC, SASL_CONTINUE, SASL_FAILED, setup_oauth_parameters(), setup_token_request(), and unlikely.
|
static |
Definition at line 60 of file fe-auth-oauth.c.
References Assert, calloc, conn, fb(), FE_OAUTH_INIT, and OAUTHBEARER_NAME.
|
static |
Definition at line 290 of file fe-auth-oauth.c.
References JSON_SUCCESS, and json_ctx::nested.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 265 of file fe-auth-oauth.c.
References Assert, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, MAX_SASL_NESTING_LEVEL, json_ctx::nested, oauth_json_has_error, oauth_json_set_error, json_ctx::target_field, and json_ctx::target_field_name.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 228 of file fe-auth-oauth.c.
References JSON_SUCCESS, and json_ctx::nested.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 237 of file fe-auth-oauth.c.
References json_ctx::discovery_uri, ERROR_OPENID_CONFIGURATION_FIELD, ERROR_SCOPE_FIELD, ERROR_STATUS_FIELD, fb(), JSON_SUCCESS, name, json_ctx::nested, json_ctx::scope, json_ctx::status, json_ctx::target_field, and json_ctx::target_field_name.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 207 of file fe-auth-oauth.c.
References Assert, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, MAX_SASL_NESTING_LEVEL, json_ctx::nested, oauth_json_has_error, oauth_json_set_error, json_ctx::target_field, and json_ctx::target_field_name.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 299 of file fe-auth-oauth.c.
References Assert, fb(), JSON_OUT_OF_MEMORY, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, JSON_TOKEN_STRING, json_ctx::nested, oauth_json_set_error, oauth_json_set_error_internal, json_ctx::target_field, json_ctx::target_field_name, and type.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 1467 of file fe-auth-oauth.c.
References Assert, fb(), fprintf, len, POISON_MASK, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by do_async(), do_cleanup(), and setup_token_request().
Definition at line 1431 of file fe-auth-oauth.c.
References conn, explicit_bzero(), fb(), free, and pg_conn::oauth_token.
Referenced by pqClosePGconn(), and PQconnectPoll().
|
static |
Definition at line 690 of file fe-auth-oauth.c.
References appendPQExpBufferChar(), appendPQExpBufferStr(), Assert, conn, errmsg, pg_conn::errorMessage, fb(), libpq_gettext, and pg_conn::sasl_state.
Referenced by run_oauth_flow(), and setup_token_request().
|
static |
Definition at line 737 of file fe-auth-oauth.c.
References pg_conn::altsock, Assert, conn, do_async(), fb(), libpq_append_conn_error(), pg_conn::oauth_token, PGINVALID_SOCKET, PGRES_POLLING_FAILED, PGRES_POLLING_OK, report_flow_error(), pg_conn::sasl_state, and json_ctx::status.
Referenced by setup_token_request().
Definition at line 1110 of file fe-auth-oauth.c.
References conn, fb(), issuer_from_well_known_uri(), libpq_append_conn_error(), pg_conn::oauth_client_id, pg_conn::oauth_discovery_uri, pg_conn::oauth_issuer, pg_conn::oauth_issuer_id, and WK_PREFIX.
Referenced by oauth_exchange().
|
static |
Definition at line 1016 of file fe-auth-oauth.c.
References Assert, pg_conn::async_auth, pg_conn::cleanup_async_auth, cleanup_oauth_flow(), conn, do_cleanup(), fb(), libpq_append_conn_error(), malloc, pg_conn::oauth_discovery_uri, pg_conn::oauth_issuer_id, pg_conn::oauth_scope, pg_conn::oauth_token, PGoauthBearerRequest::openid_configuration, poison_req_v2(), PQAUTHDATA_OAUTH_BEARER_TOKEN, PQAUTHDATA_OAUTH_BEARER_TOKEN_V2, PQauthDataHook, report_flow_error(), run_oauth_flow(), use_builtin_flow(), and PGoauthBearerRequestV2::v1.
Referenced by oauth_exchange().
|
static |
Definition at line 843 of file fe-auth-oauth.c.
Referenced by setup_token_request().
| const pg_fe_sasl_mech pg_oauth_mech |
Definition at line 47 of file fe-auth-oauth.c.
Referenced by pg_SASL_init(), pqConnectOptions2(), and PQconnectPoll().