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 "pg_config_paths.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 | oauth_json_has_error(ctx) (PQExpBufferDataBroken((ctx)->errbuf) || (ctx)->errmsg) |
#define | oauth_json_set_error(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" |
Variables | |
const pg_fe_sasl_mech | pg_oauth_mech |
#define ERROR_OPENID_CONFIGURATION_FIELD "openid-configuration" |
Definition at line 158 of file fe-auth-oauth.c.
#define ERROR_SCOPE_FIELD "scope" |
Definition at line 157 of file fe-auth-oauth.c.
#define ERROR_STATUS_FIELD "status" |
Definition at line 156 of file fe-auth-oauth.c.
#define HTTP_SCHEME "http://" |
Definition at line 323 of file fe-auth-oauth.c.
#define HTTPS_SCHEME "https://" |
Definition at line 322 of file fe-auth-oauth.c.
#define kvsep "\x01" |
Definition at line 94 of file fe-auth-oauth.c.
#define oauth_json_has_error | ( | ctx | ) | (PQExpBufferDataBroken((ctx)->errbuf) || (ctx)->errmsg) |
Definition at line 175 of file fe-auth-oauth.c.
#define oauth_json_set_error | ( | ctx, | |
... | |||
) |
Definition at line 178 of file fe-auth-oauth.c.
#define OAUTH_WK_SUFFIX "oauth-authorization-server" |
Definition at line 328 of file fe-auth-oauth.c.
#define OPENID_WK_SUFFIX "openid-configuration" |
Definition at line 327 of file fe-auth-oauth.c.
#define WK_PREFIX "/.well-known/" |
Definition at line 326 of file fe-auth-oauth.c.
|
static |
Definition at line 714 of file fe-auth-oauth.c.
References pg_conn::altsock, Assert(), PGoauthBearerRequest::cleanup, conn, free, PGINVALID_SOCKET, and pg_conn::sasl_state.
Referenced by setup_token_request().
|
static |
Definition at line 106 of file fe-auth-oauth.c.
References appendPQExpBuffer(), Assert(), buf, conn, initPQExpBuffer(), kvsep, libpq_append_conn_error(), pg_conn::oauth_token, PQExpBufferDataBroken, and termPQExpBuffer().
Referenced by oauth_exchange().
|
static |
Definition at line 482 of file fe-auth-oauth.c.
References JsonSemAction::array_start, Assert(), cleanup(), conn, json_ctx::discovery_uri, err(), json_ctx::errbuf, errmsg(), json_ctx::errmsg, 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_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().
|
static |
Definition at line 335 of file fe-auth-oauth.c.
References Assert(), conn, HTTP_SCHEME, HTTPS_SCHEME, libpq_append_conn_error(), oauth_unsafe_debugging_enabled(), OAUTH_WK_SUFFIX, OPENID_WK_SUFFIX, pg_strncasecmp(), and WK_PREFIX.
Referenced by handle_oauth_sasl_error(), and setup_oauth_parameters().
|
static |
Definition at line 1342 of file fe-auth-oauth.c.
|
static |
Definition at line 1117 of file fe-auth-oauth.c.
References Assert(), pg_conn::async_auth, pg_conn::client_finished_auth, client_initial_response(), conn, 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 84 of file fe-auth-oauth.c.
|
static |
Definition at line 53 of file fe-auth-oauth.c.
References Assert(), calloc, conn, FE_OAUTH_INIT, and OAUTHBEARER_NAME.
|
static |
Definition at line 240 of file fe-auth-oauth.c.
References Assert(), json_ctx::errmsg, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, libpq_gettext, 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 203 of file fe-auth-oauth.c.
References JSON_SUCCESS, and json_ctx::nested.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 212 of file fe-auth-oauth.c.
References json_ctx::discovery_uri, ERROR_OPENID_CONFIGURATION_FIELD, ERROR_SCOPE_FIELD, ERROR_STATUS_FIELD, 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 185 of file fe-auth-oauth.c.
References Assert(), JSON_SEM_ACTION_FAILED, JSON_SUCCESS, libpq_gettext, 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 261 of file fe-auth-oauth.c.
References Assert(), json_ctx::errmsg, JSON_OUT_OF_MEMORY, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, JSON_TOKEN_STRING, libpq_gettext, json_ctx::nested, oauth_json_set_error, json_ctx::target_field, json_ctx::target_field_name, and type.
Referenced by handle_oauth_sasl_error().
bool oauth_unsafe_debugging_enabled | ( | void | ) |
Definition at line 1367 of file fe-auth-oauth.c.
Referenced by issuer_from_well_known_uri().
void pqClearOAuthToken | ( | PGconn * | conn | ) |
Definition at line 1353 of file fe-auth-oauth.c.
References conn, explicit_bzero(), free, and pg_conn::oauth_token.
Referenced by pqClosePGconn(), and PQconnectPoll().
|
static |
Definition at line 655 of file fe-auth-oauth.c.
References pg_conn::altsock, PGoauthBearerRequest::async, conn, libpq_append_conn_error(), pg_conn::oauth_token, PGINVALID_SOCKET, PGRES_POLLING_FAILED, PGRES_POLLING_OK, pg_conn::sasl_state, json_ctx::status, and PGoauthBearerRequest::token.
Referenced by setup_token_request().
|
static |
Definition at line 1032 of file fe-auth-oauth.c.
References conn, 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 958 of file fe-auth-oauth.c.
References Assert(), pg_conn::async_auth, PGoauthBearerRequest::cleanup, pg_conn::cleanup_async_auth, cleanup_user_oauth_flow(), conn, libpq_append_conn_error(), malloc, pg_conn::oauth_discovery_uri, pg_conn::oauth_scope, pg_conn::oauth_token, PGoauthBearerRequest::openid_configuration, PQAUTHDATA_OAUTH_BEARER_TOKEN, PQauthDataHook, run_user_oauth_flow(), PGoauthBearerRequest::token, and use_builtin_flow().
Referenced by oauth_exchange().
bool use_builtin_flow | ( | PGconn * | conn, |
fe_oauth_state * | state | ||
) |
Definition at line 749 of file fe-auth-oauth.c.
Referenced by setup_token_request().
const pg_fe_sasl_mech pg_oauth_mech |
Definition at line 40 of file fe-auth-oauth.c.
Referenced by pg_SASL_init(), pqConnectOptions2(), and PQconnectPoll().