PostgreSQL Source Code git master
Loading...
Searching...
No Matches
oauth.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * oauth.h
4 * Interface to libpq/auth-oauth.c
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/libpq/oauth.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef PG_OAUTH_H
14#define PG_OAUTH_H
15
16#include "libpq/libpq-be.h"
17#include "libpq/sasl.h"
18
20
22{
23 /* Holds the server's PG_VERSION_NUM. Reserved for future extensibility. */
25
26 /*
27 * Private data pointer for use by a validator module. This can be used to
28 * store state for the module that will be passed to each of its
29 * callbacks.
30 */
33
35{
36 /*
37 * Should be set to true if the token carries sufficient permissions for
38 * the bearer to connect.
39 */
41
42 /*
43 * If the token authenticates the user, this should be set to a palloc'd
44 * string containing the SYSTEM_USER to use for HBA mapping. Consider
45 * setting this even if result->authorized is false so that DBAs may use
46 * the logs to match end users to token failures.
47 *
48 * This is required if the module is not configured for ident mapping
49 * delegation. See the validator module documentation for details.
50 */
51 char *authn_id;
52
53 /*
54 * When validation fails, this may optionally be set to a string
55 * containing an explanation for the failure. It will be sent to the
56 * server log only; it is not provided to the client, and it's ignored if
57 * validation succeeds.
58 *
59 * This description will be attached to the final authentication failure
60 * message in the logs, as a DETAIL, which may be preferable to separate
61 * ereport() calls that have to be correlated by the reader.
62 *
63 * This string may be either of static duration or palloc'd.
64 */
67
68/*
69 * Validator module callbacks
70 *
71 * These callback functions should be defined by validator modules and returned
72 * via _PG_oauth_validator_module_init(). ValidatorValidateCB is the only
73 * required callback. For more information about the purpose of each callback,
74 * refer to the OAuth validator modules documentation.
75 */
79 const char *token, const char *role,
81
82/*
83 * Identifies the compiled ABI version of the validator module. Since the server
84 * already enforces the PG_MODULE_MAGIC number for modules across major
85 * versions, this is reserved for emergency use within a stable release line.
86 * May it never need to change.
87 */
88#define PG_OAUTH_VALIDATOR_MAGIC 0x20250220
89
98
99/*
100 * A validator can register a list of custom option names during its startup_cb,
101 * then later retrieve the user settings for each during validation. This
102 * enables per-HBA-line configuration. For more information, refer to the OAuth
103 * validator modules documentation.
104 */
106 const char *opts[]);
107extern const char *GetOAuthHBAOption(const ValidatorModuleState *state,
108 const char *optname);
109
110/*
111 * Type of the shared library symbol _PG_oauth_validator_module_init which is
112 * required for all validator modules. This function will be invoked during
113 * module loading.
114 */
115typedef const OAuthValidatorCallbacks *(*OAuthValidatorModuleInit) (void);
117
118/* Implementation */
120
121extern bool check_oauth_validator(HbaLine *hbaline, int elevel, char **err_msg);
122extern bool valid_oauth_hba_option_name(const char *name);
123
124#endif /* PG_OAUTH_H */
#define PGDLLIMPORT
Definition c.h:1421
#define PGDLLEXPORT
Definition c.h:1436
uint32_t uint32
Definition c.h:624
uint32 result
#define token
PGDLLEXPORT const OAuthValidatorCallbacks * _PG_oauth_validator_module_init(void)
bool(* ValidatorValidateCB)(const ValidatorModuleState *state, const char *token, const char *role, ValidatorModuleResult *result)
Definition oauth.h:78
void(* ValidatorShutdownCB)(ValidatorModuleState *state)
Definition oauth.h:77
void(* ValidatorStartupCB)(ValidatorModuleState *state)
Definition oauth.h:76
const char * GetOAuthHBAOption(const ValidatorModuleState *state, const char *optname)
bool check_oauth_validator(HbaLine *hbaline, int elevel, char **err_msg)
Definition auth-oauth.c:857
bool valid_oauth_hba_option_name(const char *name)
PGDLLIMPORT char * oauth_validator_libraries_string
Definition auth-oauth.c:35
PGDLLIMPORT const pg_be_sasl_mech pg_be_oauth_mech
Definition auth-oauth.c:54
void RegisterOAuthHBAOptions(ValidatorModuleState *state, int num, const char *opts[])
Definition auth-oauth.c:949
static AmcheckOptions opts
Definition pg_amcheck.c:112
static int fb(int x)
Definition hba.h:95
ValidatorShutdownCB shutdown_cb
Definition oauth.h:95
ValidatorValidateCB validate_cb
Definition oauth.h:96
ValidatorStartupCB startup_cb
Definition oauth.h:94
char * error_detail
Definition oauth.h:65
void * private_data
Definition oauth.h:31
const char * name