mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
GSSAPI encryption support
On both the frontend and backend, prepare for GSSAPI encryption support by moving common code for error handling into a separate file. Fix a TODO for handling multiple status messages in the process. Eliminate the OIDs, which have not been needed for some time. Add frontend and backend encryption support functions. Keep the context initiation for authentication-only separate on both the frontend and backend in order to avoid concerns about changing the requested flags to include encryption support. In postmaster, pull GSSAPI authorization checking into a shared function. Also share the initiator name between the encryption and non-encryption codepaths. For HBA, add "hostgssenc" and "hostnogssenc" entries that behave similarly to their SSL counterparts. "hostgssenc" requires either "gss", "trust", or "reject" for its authentication. Similarly, add a "gssencmode" parameter to libpq. Supported values are "disable", "require", and "prefer". Notably, negotiation will only be attempted if credentials can be acquired. Move credential acquisition into its own function to support this behavior. Add a simple pg_stat_gssapi view similar to pg_stat_ssl, for monitoring if GSSAPI authentication was used, what principal was used, and if encryption is being used on the connection. Finally, add documentation for everything new, and update existing documentation on connection security. Thanks to Michael Paquier for the Windows fixes. Author: Robbie Harwood, with changes to the read/write functions by me. Reviewed in various forms and at different times by: Michael Paquier, Andres Freund, David Steele. Discussion: https://www.postgresql.org/message-id/flat/jlg1tgq1ktm.fsf@thriss.redhat.com
This commit is contained in:
@@ -480,9 +480,15 @@ struct pg_conn
|
||||
#endif /* USE_OPENSSL */
|
||||
#endif /* USE_SSL */
|
||||
|
||||
char *gssencmode; /* GSS mode (require,prefer,disable) */
|
||||
#ifdef ENABLE_GSS
|
||||
gss_ctx_id_t gctx; /* GSS context */
|
||||
gss_name_t gtarg_nam; /* GSS target name */
|
||||
|
||||
/* The following are encryption-only */
|
||||
bool try_gss; /* GSS attempting permitted */
|
||||
bool gssenc; /* GSS encryption is usable */
|
||||
gss_cred_id_t gcred; /* GSS credential temp storage. */
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SSPI
|
||||
@@ -749,6 +755,23 @@ extern int pgtls_verify_peer_name_matches_certificate_guts(PGconn *conn,
|
||||
int *names_examined,
|
||||
char **first_name);
|
||||
|
||||
/* === GSSAPI === */
|
||||
|
||||
#ifdef ENABLE_GSS
|
||||
|
||||
/*
|
||||
* Establish a GSSAPI-encrypted connection.
|
||||
*/
|
||||
extern PostgresPollingStatusType pqsecure_open_gss(PGconn *conn);
|
||||
|
||||
/*
|
||||
* Read and write functions for GSSAPI-encrypted connections, with internal
|
||||
* buffering to handle nonblocking sockets.
|
||||
*/
|
||||
extern ssize_t pg_GSS_write(PGconn *conn, const void *ptr, size_t len);
|
||||
extern ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len);
|
||||
#endif
|
||||
|
||||
/* === miscellaneous macros === */
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user