Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement clientauth feature #227

Merged
merged 38 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d221c01
Initial implementation of clientauth
adamguo0 Aug 9, 2023
5adff7f
Process queue entries one at a time
adamguo0 Aug 17, 2023
d4c75d6
Add GUC to skip databases
adamguo0 Aug 17, 2023
ffca9b1
Call previous client auth hook before ours
adamguo0 Aug 18, 2023
18ac02d
Fix compiler warnings
adamguo0 Aug 18, 2023
eb96dfa
Add pgtle.enable_clientauth = require test
adamguo0 Aug 18, 2023
5b17684
Fix tests for PG13 and 14
adamguo0 Aug 18, 2023
16a2a01
Add some comments
adamguo0 Aug 18, 2023
2924d17
Add clientauth to pgtle.pg_tle_features enum
adamguo0 Aug 18, 2023
3e591ed
Add pg_tle--1.1.1.sql to Makefile
adamguo0 Aug 18, 2023
bdda8fb
Improve signalling stability
adamguo0 Aug 19, 2023
ba11052
Fix the race condition that left an entry unprocessed
adamguo0 Aug 22, 2023
6bd7ba2
Mark helper functions as static
adamguo0 Aug 22, 2023
5321724
Assign each worker a partition of the queue
adamguo0 Aug 23, 2023
4c2d378
Apply pg_indent
adamguo0 Aug 24, 2023
dbe01f0
Add pg_tle--$(EXTVERSION).sql back to EXTRA_CLEAN
adamguo0 Aug 24, 2023
9d088d9
pg_indent and small changes
adamguo0 Aug 24, 2023
804ddb9
Add an index offset to worker loop when checking for pending entries
adamguo0 Aug 24, 2023
b4458cc
Refactor clientauth users_to_skip and databases_to_skip checks
adamguo0 Aug 28, 2023
92b90bf
Refactor worker query logic
adamguo0 Aug 28, 2023
8875a03
Move SPI calls to clientauth_launcher_run_user_functions
adamguo0 Aug 28, 2023
f5f2d5f
Set enable_clientauth to POSTMASTER and other fixes
adamguo0 Aug 31, 2023
f56f12e
Fix stale entry bug
adamguo0 Sep 5, 2023
38d4637
Signal BGW before doing any work in client
adamguo0 Sep 5, 2023
944f423
Handle pg_upgrade
adamguo0 Sep 5, 2023
95245f3
Change LW_EXCLUSIVE to LW_SHARED when reading only
adamguo0 Sep 5, 2023
acee3f3
Check IsBinaryUpgrade before registering hooks
adamguo0 Sep 6, 2023
fa05713
Set version to 1.2.0
adamguo0 Sep 6, 2023
5689169
Replace SELECT func with SELECT * FROM func
adamguo0 Sep 6, 2023
511c727
Remove elog
adamguo0 Sep 6, 2023
ac30344
Rename WAIT_EVENT_MQ_* to WAIT_EVENT_MESSAGE_QUEUE_*
adamguo0 Sep 6, 2023
2c03e67
Set pgtle.enable_clientauth context back to SIGHUP
adamguo0 Sep 6, 2023
5e9c01b
Fix test numbering
adamguo0 Sep 6, 2023
57c400f
Update deadlock comment
adamguo0 Sep 6, 2023
6e13965
ereport if SPI_execute fails
adamguo0 Sep 7, 2023
bd76413
Report SPI error if < 0 instead of != SPI_OK_SELECT
adamguo0 Sep 7, 2023
42fadf0
Revert "Report SPI error if < 0 instead of != SPI_OK_SELECT"
adamguo0 Sep 7, 2023
29dfe78
Remove extra compatibility defines
adamguo0 Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
EXTENSION = pg_tle
EXTVERSION = 1.1.1
EXTVERSION = 1.2.0

SCHEMA = pgtle
MODULE_big = $(EXTENSION)

OBJS = src/tleextension.o src/guc-file.o src/feature.o src/passcheck.o src/uni_api.o src/datatype.o
OBJS = src/tleextension.o src/guc-file.o src/feature.o src/passcheck.o src/uni_api.o src/datatype.o src/clientauth.o

EXTRA_CLEAN = src/guc-file.c pg_tle.control pg_tle--$(EXTVERSION).sql
DATA = pg_tle.control pg_tle--1.0.0.sql pg_tle--1.0.0--1.0.1.sql pg_tle--1.0.1--1.0.4.sql pg_tle--1.0.4--1.1.1.sql pg_tle--1.1.0--1.1.1.sql
DATA = pg_tle.control pg_tle--1.0.0.sql pg_tle--1.0.0--1.0.1.sql pg_tle--1.0.1--1.0.4.sql pg_tle--1.0.4.sql pg_tle--1.0.4--1.1.1.sql pg_tle--1.1.0--1.1.1.sql pg_tle--1.1.1.sql pg_tle--1.1.1--1.2.0.sql

REGRESS = pg_tle_api pg_tle_management pg_tle_injection pg_tle_perms pg_tle_requires pg_tle_datatype pg_tle_versions

Expand Down
21 changes: 21 additions & 0 deletions include/clientauth.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* clientauth.h
*
* contains the changes needed by uni_api to load the functionality for
* clientauth.
*/
void clientauth_init();
14 changes: 14 additions & 0 deletions include/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,5 +557,19 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
#define CHECK_CAN_SET_ROLE(member, role) check_can_set_role(member, role)
#endif

/*
* PostgreSQL version 17+
*
* Renames WAIT_EVENT_MQ_* to WAIT_EVENT_MESSAGE_QUEUE_*
*/
#if (PG_VERSION_NUM < 170000)
#define WAIT_EVENT_MESSAGE_QUEUE_RECEIVE WAIT_EVENT_MQ_RECEIVE
#define WAIT_EVENT_MESSAGE_QUEUE_PUT_MESSAGE WAIT_EVENT_MQ_PUT_MESSAGE
#define WAIT_EVENT_WAL_SENDER_WAIT_FOR_WAL WAIT_EVENT_WAL_SENDER_WAIT_WAL
#define WAIT_EVENT_MESSAGE_QUEUE_SEND WAIT_EVENT_MQ_SEND
#define WAIT_EVENT_MESSAGE_QUEUE_RECEIVE WAIT_EVENT_MQ_RECEIVE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's duplicated, and we're only using one right might not need to declare all

#define WAIT_EVENT_MESSAGE_QUEUE_INTERNAL WAIT_EVENT_MQ_INTERNAL
#endif


#endif /* SET_USER_COMPAT_H */
2 changes: 2 additions & 0 deletions include/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ static const struct config_enum_entry feature_mode_options[] = {

List * feature_proc(const char *featurename);

bool check_string_in_guc_list(const char *str, const char *guc_var, const char *guc_name);

#endif /* FEATURE_H */
37 changes: 37 additions & 0 deletions pg_tle--1.1.1--1.2.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* Updates since v1.1.1
* 1. Introduced clientauth feature
*/

-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pg_tle" to load this file. \quit

ALTER TYPE pgtle.pg_tle_features ADD VALUE 'clientauth';

CREATE TYPE pgtle.clientauth_port_subset AS (
noblock boolean,

remote_host text,
remote_hostname text,
remote_hostname_resolv integer,
remote_hostname_errcode integer,

database_name text,
user_name text
);
Loading