Skip to content

Commit 02f4e17

Browse files
case-insenitive Bearer check #134 (#135)
1 parent 03d9553 commit 02f4e17

5 files changed

+17
-13
lines changed

openssl.dockerfile

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
ARG BASE_IMAGE
1+
ARG BASE_IMAGE=debian:bookworm-slim
22

33
FROM ${BASE_IMAGE}
4-
ARG SRC_DIR=/tmp/openssl-src
5-
ARG OUT_DIR=/usr/local/.openssl
6-
ARG SSL_VERSION
4+
ARG SSL_VERSION=3.2.1
5+
ENV SRC_DIR=/tmp/openssl-src
6+
ENV OUT_DIR=/usr/local/.openssl
77
RUN <<`
88
set -e
99
apt-get update
@@ -13,8 +13,8 @@ RUN <<`
1313
`
1414
WORKDIR ${SRC_DIR}
1515
RUN <<`
16-
set -e
17-
curl --silent -O https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz
16+
set -ex
17+
curl --silent -LO https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz
1818
tar -xf openssl-${SSL_VERSION}.tar.gz --strip-components=1
1919
`
2020
RUN ./config --prefix=${OUT_DIR} --openssldir=${OUT_DIR} shared zlib
@@ -34,4 +34,4 @@ RUN <<`
3434
ln -sf ${OUT_DIR}/lib64/libcrypto.so.3 /lib/x86_64-linux-gnu/libcrypto.so.3
3535
`
3636
WORKDIR /
37-
#RUN rm -rf ${SRC_DIR}
37+
RUN rm -rf ${SRC_DIR}

scripts.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ all() {
4040
verify_and_build_base_image() {
4141
local image=${SSL_IMAGE_MAP[$SSL_VERSION]}
4242
local baseImage=${image%%:*}
43-
43+
4444
if [ -z ${image} ]; then
4545
echo "Base image not set for SSL version :${SSL_VERSION}"
4646
exit 1
4747
else
48-
printf "${MAGENTA}Building base image for SSL ${SSL_VERSION}...${NC}\n"
49-
docker image build \
48+
printf "${MAGENTA}Building ${baseImage} base image for SSL ${SSL_VERSION}...${NC}\n"
49+
docker buildx build \
5050
--build-arg BASE_IMAGE=debian:${baseImage} \
5151
--build-arg SSL_VERSION=${SSL_VERSION} \
5252
-f openssl.dockerfile \

src/ngx_http_auth_jwt_module.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static char *get_jwt(ngx_http_request_t *r, ngx_str_t jwt_location)
630630
{
631631
static const char *BEARER_PREFIX = "Bearer ";
632632

633-
if (ngx_strncmp(jwtHeaderVal->value.data, BEARER_PREFIX, strlen(BEARER_PREFIX)) == 0)
633+
if (ngx_strncasecmp(jwtHeaderVal->value.data, (u_char *)BEARER_PREFIX, strlen(BEARER_PREFIX)) == 0)
634634
{
635635
ngx_str_t jwtHeaderValWithoutBearer = jwtHeaderVal->value;
636636

test/docker-compose-test.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.3'
2-
31
services:
42

53
nginx:

test/test.sh

+6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ main() {
143143
-r "< Test-Authorization: Bearer ${JWT_HS256_VALID}" \
144144
-x "--header \"Authorization: Bearer ${JWT_HS256_VALID}\""
145145

146+
run_test -n 'when auth enabled with Authorization header with Bearer, lower-case "bearer" should be accepted' \
147+
-p '/secure/auth-header/default/proxy-header' \
148+
-c '200' \
149+
-r "< Test-Authorization: bearer ${JWT_HS256_VALID}" \
150+
-x "--header \"Authorization: bearer ${JWT_HS256_VALID}\""
151+
146152
run_test -n 'when auth enabled with default algorithm and no JWT cookie, returns 302' \
147153
-p '/secure/cookie/default' \
148154
-c '302'

0 commit comments

Comments
 (0)