Skip to content

Commit 9f4a69f

Browse files
committed
Fix PostgreSQL 15 SSL authentication and test with SSL
scram_sha_256 auth requires lua-resty-openssl, which currently has some issues with the latest OpenResty versions, so temporarily patch it.
1 parent a666501 commit 9f4a69f

File tree

7 files changed

+56
-3
lines changed

7 files changed

+56
-3
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ COPY src/api-umbrella/web-app/package.json src/api-umbrella/web-app/pnpm-lock.ya
6262
COPY tasks/app-deps/web-app/pnpm /app/tasks/app-deps/web-app/
6363
RUN make app-deps:web-app:pnpm && make clean:dev
6464

65-
COPY build/patches/lrexlib-pcre2.patch /app/build/patches/
65+
COPY build/patches/lrexlib-pcre2.patch build/patches/lua-resty-openssl.patch /app/build/patches/
6666
COPY tasks/app-deps/luarocks /app/tasks/app-deps/
6767
RUN make app-deps:luarocks && make clean:dev
6868

Dockerfile-postgres

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM public.ecr.aws/docker/library/postgres:15.10-bookworm
2+
COPY ./test/config/ssl_test.crt /var/lib/postgresql/server.crt
3+
COPY ./test/config/ssl_test.key /var/lib/postgresql/server.key
4+
RUN chown postgres /var/lib/postgresql/server.key /var/lib/postgresql/server.key && chmod 600 /var/lib/postgresql/server.key
5+
6+
CMD ["postgres", "-c", "ssl=on", "-c", "ssl_cert_file=/var/lib/postgresql/server.crt", "-c", "ssl_key_file=/var/lib/postgresql/server.key"]

build/patches/lua-resty-openssl.patch

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/lib/resty/openssl/auxiliary/nginx.lua b/lib/resty/openssl/auxiliary/nginx.lua
2+
index 5755d8a..540cbc1 100644
3+
--- a/lib/resty/openssl/auxiliary/nginx.lua
4+
+++ b/lib/resty/openssl/auxiliary/nginx.lua
5+
@@ -44,8 +44,9 @@ else
6+
local ngx_has_http_v3 = ngx_configure and ngx_configure:find("--with-http_v3_module", 1, true)
7+
-- https://github.com/nginx/nginx/blob/master/src/core/ngx_connection.h
8+
if ngx_version == 1017008 or ngx_version == 1019003 or ngx_version == 1019009
9+
- or ngx_version == 1021004 or (not ngx_has_http_v3 and ngx_version == 1025003) then
10+
- -- 1.17.8, 1.19.3, 1.19.9, 1.21.4, 1.25.3
11+
+ or ngx_version == 1021004
12+
+ or (not ngx_has_http_v3 and (ngx_version == 1025003 or ngx_version == 1027001)) then
13+
+ -- 1.17.8, 1.19.3, 1.19.9, 1.21.4, 1.25.3, 1.27.1
14+
ffi.cdef [[
15+
typedef struct ngx_proxy_protocol_s ngx_proxy_protocol_t;
16+
17+
@@ -82,7 +83,7 @@ else
18+
// trimmed
19+
} ngx_connection_s;
20+
]]
21+
- elseif ngx_has_http_v3 and ngx_version == 1025003 then
22+
+ elseif ngx_has_http_v3 and (ngx_version == 1025003 or ngx_version == 1027001) then
23+
-- 1.25.3
24+
ffi.cdef [[
25+
typedef struct ngx_proxy_protocol_s ngx_proxy_protocol_t;
26+
@@ -255,7 +256,7 @@ else
27+
ngx.config.ngx_lua_version and
28+
ngx.config.ngx_lua_version
29+
30+
- if ngx_lua_version >= 10019 and ngx_lua_version <= 10026 then
31+
+ if ngx_lua_version >= 10019 and ngx_lua_version <= 10027 then
32+
-- https://github.com/openresty/lua-nginx-module/blob/master/src/ngx_http_lua_socket_tcp.h
33+
ffi.cdef[[
34+
typedef struct {

config/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ fluent_bit:
9898
geoip:
9999
db_update_frequency: false
100100
postgresql:
101+
ssl: true
102+
ssl_required: true
101103
database: api_umbrella_test
102104
password: dev_password
103105
migrations:

docker-compose.ci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ services:
99
- postgres
1010
- opensearch
1111
postgres:
12-
image: postgres:15.10-bookworm
12+
build:
13+
context: .
14+
dockerfile: Dockerfile-postgres
1315
environment:
1416
POSTGRES_PASSWORD: dev_password
1517
healthcheck:

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ services:
2424
- postgres
2525
- opensearch
2626
postgres:
27-
image: postgres:15.10-bookworm
27+
build:
28+
context: .
29+
dockerfile: Dockerfile-postgres
2830
environment:
2931
POSTGRES_PASSWORD: dev_password
3032
volumes:

tasks/app-deps/luarocks

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ extra_args=(
1717

1818
luarocks_install "./api-umbrella-git-1.rockspec" "git-1" "${extra_args[@]}"
1919

20+
# Temporary workaround for lua-resty-openssl and OpenResty 1.27:
21+
# https://github.com/fffonion/lua-resty-openssl/pull/200
22+
(
23+
cd "${APP_VENDOR_LUA_SHARE_DIR}/resty/openssl"
24+
patch -p4 < "$SOURCE_DIR/build/patches/lua-resty-openssl.patch"
25+
)
26+
2027
# lrexlib-pcre2
2128
(
2229
lrexlib_pcre2_version="2.9.2-1"

0 commit comments

Comments
 (0)