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"
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 153 of file fe-auth-oauth.c.
#define ERROR_SCOPE_FIELD "scope" |
Definition at line 152 of file fe-auth-oauth.c.
#define ERROR_STATUS_FIELD "status" |
Definition at line 151 of file fe-auth-oauth.c.
#define HTTP_SCHEME "http://" |
Definition at line 318 of file fe-auth-oauth.c.
#define HTTPS_SCHEME "https://" |
Definition at line 317 of file fe-auth-oauth.c.
#define kvsep "\x01" |
Definition at line 89 of file fe-auth-oauth.c.
#define oauth_json_has_error | ( | ctx | ) | (PQExpBufferDataBroken((ctx)->errbuf) || (ctx)->errmsg) |
Definition at line 170 of file fe-auth-oauth.c.
#define oauth_json_set_error | ( | ctx, | |
... | |||
) |
Definition at line 173 of file fe-auth-oauth.c.
#define OAUTH_WK_SUFFIX "oauth-authorization-server" |
Definition at line 323 of file fe-auth-oauth.c.
#define OPENID_WK_SUFFIX "openid-configuration" |
Definition at line 322 of file fe-auth-oauth.c.
#define WK_PREFIX "/.well-known/" |
Definition at line 321 of file fe-auth-oauth.c.
|
static |
Definition at line 709 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 101 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 477 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 330 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 1133 of file fe-auth-oauth.c.
|
static |
Definition at line 908 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 79 of file fe-auth-oauth.c.
|
static |
Definition at line 48 of file fe-auth-oauth.c.
References Assert(), calloc, conn, FE_OAUTH_INIT, and OAUTHBEARER_NAME.
|
static |
Definition at line 235 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 198 of file fe-auth-oauth.c.
References JSON_SUCCESS, and json_ctx::nested.
Referenced by handle_oauth_sasl_error().
|
static |
Definition at line 207 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 180 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 256 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 1158 of file fe-auth-oauth.c.
Referenced by issuer_from_well_known_uri(), and pg_fe_run_oauth_flow_impl().
void pqClearOAuthToken | ( | PGconn * | conn | ) |
Definition at line 1144 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 650 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 823 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 741 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, pg_fe_cleanup_oauth_flow(), pg_fe_run_oauth_flow(), PQAUTHDATA_OAUTH_BEARER_TOKEN, PQauthDataHook, run_user_oauth_flow(), and PGoauthBearerRequest::token.
Referenced by oauth_exchange().
const pg_fe_sasl_mech pg_oauth_mech |
Definition at line 35 of file fe-auth-oauth.c.
Referenced by pg_SASL_init(), pqConnectOptions2(), and PQconnectPoll().