Skip to content

Merge orig TeslaGov with jaken1986 fork #1

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

Open
wants to merge 141 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
c84ef0a
Additional test and log msg
fitzyjoe Oct 30, 2017
caee28d
test
fitzyjoe Oct 30, 2017
049ba37
Added search headers function
fitzyjoe Oct 30, 2017
8c643f2
debug
fitzyjoe Oct 30, 2017
dba2163
debug
fitzyjoe Oct 30, 2017
9aad8e0
Check length and content of strings and fixed test
fitzyjoe Oct 30, 2017
3dbb129
debug
fitzyjoe Oct 30, 2017
db46b07
debug
fitzyjoe Oct 30, 2017
1f38838
strncmp doesn't work with u_char *
fitzyjoe Oct 30, 2017
dd5c178
Test had bad newlines
fitzyjoe Oct 30, 2017
8c77e17
remove spaces from tests
fitzyjoe Oct 30, 2017
0e01b36
clean up
fitzyjoe Oct 30, 2017
060185d
didn't like the static const strings
fitzyjoe Oct 30, 2017
db01184
name test better
fitzyjoe Oct 30, 2017
358c168
pointing at branch to test
fitzyjoe Oct 30, 2017
9927fb9
Corrected comments
fitzyjoe Oct 31, 2017
4ef1890
Cleaner tests
fitzyjoe Oct 31, 2017
f538760
Merge pull request #12 from TeslaGov/joefitz/validate-authorization-h…
fitzyjoe Oct 31, 2017
3852372
use epel7 yum repo to get nginx and associated tweaks
fitzyjoe Nov 7, 2017
aba59c3
Merge pull request #14 from TeslaGov/joefitz/use-epel7-nginx-1.10.2
fitzyjoe Nov 7, 2017
1439114
optionally redirect or return unauthorized
fitzyjoe Nov 13, 2017
10bd80d
Testing no redirect
fitzyjoe Nov 14, 2017
20026b6
fix text for test
fitzyjoe Nov 14, 2017
2be3681
Merge pull request #15 from TeslaGov/joefitz/optionally-redirect
fitzyjoe Nov 14, 2017
85e2a1c
EPEL upgraded nginx from 1.10.2 to 1.12.2
fitzyjoe Dec 1, 2017
522d931
Merge pull request #17 from TeslaGov/joefitz/epel-upgrade
fitzyjoe Dec 1, 2017
629149b
Log userid and email in nginx access logs.
fitzyjoe Jan 16, 2018
9cb2245
Merge pull request #18 from TeslaGov/joefitz/log-userid
fitzyjoe Jan 16, 2018
203e43e
copy so out of container
fitzyjoe Jan 26, 2018
36d9054
Merge pull request #19 from TeslaGov/joefitz/copy-so-out-of-container
fitzyjoe Jan 26, 2018
a0a4bfa
removed authorization header check
fitzyjoe Jan 31, 2018
e42d2a0
Merge pull request #20 from TeslaGov/joefitz/remove-authorization-hea…
fitzyjoe Jan 31, 2018
c861b1e
Create LICENSE
fitzyjoe Feb 2, 2018
6c60776
Joefitz/optional auth header (#24)
fitzyjoe Feb 5, 2018
6e1f280
Typo for test status
fitzyjoe Feb 6, 2018
6aa585f
Update README.md
fitzyjoe Feb 6, 2018
8fcda49
only set headers for sub and email if they exist in the jet (#29)
fitzyjoe Apr 10, 2018
2ab3fd3
RSA Key Validation Support (#30)
TimUnderhay Apr 25, 2018
4aab233
Test for RSA Support
fitzyjoe Apr 25, 2018
7593b72
build.sh fix for MacOS Docker.
TimUnderhay May 24, 2018
e5df258
I had checked this in by mistake at some point.
fitzyjoe May 25, 2018
1b00254
call jwt_free
fitzyjoe May 30, 2018
0686f3a
bump libjwt version
fitzyjoe Jun 8, 2018
5f244f8
37: Removed auth_jwt_redirect and auth_jwt_loginurl directives
max-lt Jun 8, 2018
df7008a
Removed a deleted direcitve reference in readme.
max-lt Jun 8, 2018
cfea570
allow options requests
fitzyjoe Jun 9, 2018
752ca9c
Use a bash function for tests
max-lt Jun 4, 2018
2958537
Using local for test function arguments
max-lt Jun 4, 2018
15a878a
Removed set -e for test
max-lt Jun 4, 2018
5ed9041
Reverted OS selection block in tests
max-lt Jun 8, 2018
b4e68b9
Merge branch 'master' into jwt-37
Maxx-T Jun 13, 2018
ae57c6b
Dockerize tests
kevinmichaelchen Jun 9, 2018
43ab8d5
Merge branch 'master' into jwt-37
fitzyjoe Sep 21, 2018
4ea3dcb
Update README.md
fitzyjoe Jan 7, 2019
ca93a93
Update README.md
fitzyjoe Jan 7, 2019
80d89d9
Update README.md
fitzyjoe Jan 8, 2019
bf24cbe
Works for NGINX version 1.16.1 in EPEL
fitzyjoe Jul 2, 2020
734527e
Merge branch 'master' into pr/42
fitzyjoe Jul 2, 2020
f6e8452
Merge pull request #54 from TeslaGov/pr/42
fitzyjoe Jul 2, 2020
820b1a4
Update for EPEL7 nginx 1.16.1, updated jansson, updated libjwt
fitzyjoe Jul 6, 2020
6384381
upgrade libjwt, copy out all binaries
fitzyjoe Jul 7, 2020
02c4a99
rearrange dockerfile
fitzyjoe Jul 7, 2020
3f93751
Copy the PC files out of the docker image
fitzyjoe Jul 13, 2020
f542086
Ignore the PC files
fitzyjoe Jul 13, 2020
9908b1b
Revert "Merge pull request #54 from TeslaGov/pr/42"
fitzyjoe Jul 13, 2020
891467e
downgrade libjwt and libjansson
fitzyjoe Jul 17, 2020
758ff80
Use nginx.org yum repo instead of epel
fitzyjoe Aug 24, 2021
59ed4f9
Fix possible overflow - thanks @eutychus
fitzyjoe Aug 24, 2021
1653ef1
PEM key file support (#56)
penumbra23 Aug 25, 2021
148987d
added NGINX_VERSION to Makefile to allow for overriding
JoshMcCullough May 20, 2022
e959c0c
Docker / build refactor & update Nginx (#69)
TimUnderhay Jun 8, 2022
16ea0fe
Dockerfile formatting
JoshMcCullough Jun 8, 2022
9f8991f
Makefile cleanup
JoshMcCullough Jun 8, 2022
60b6f4b
add task to copy binaries from container
JoshMcCullough Jun 8, 2022
aa024c5
add option to not extract sub -- fixes #66 (#70)
JoshMcCullough Jun 8, 2022
8f39e48
Do not respond with a "Location" header when redirects are disabled (…
hvt Aug 15, 2022
1cf8606
update cookie name in README and test
JoshMcCullough Oct 28, 2022
bd09118
update README
JoshMcCullough Oct 28, 2022
223a4e2
fix tests
JoshMcCullough Oct 28, 2022
d150705
rename variable for clarity
JoshMcCullough Nov 8, 2022
d7c3cb4
add support for higher-bit HS/RS algorithms (#80)
JoshMcCullough Nov 9, 2022
69e6e53
Fix link with jansson (#63)
orgads Nov 9, 2022
4cf353b
update README with build-related info
JoshMcCullough Nov 9, 2022
829886f
fix for #75 (#81)
JoshMcCullough Nov 10, 2022
a5656b1
fix cp_bin function
JoshMcCullough Mar 15, 2023
8e5031b
update README
JoshMcCullough Apr 19, 2023
8014cdc
Fix: Only call `docker rmi` if there are images to prune (#85)
SmartArray Apr 19, 2023
8508334
fix(docker-buildkit): Make stage names lowercase (#84)
SmartArray Apr 19, 2023
583fffe
update to support extracting any claim to request/response headers + …
JoshMcCullough Apr 20, 2023
ac147ef
update Dockerfile; update scripts.sh (#88)
JoshMcCullough Apr 24, 2023
bb9534e
update README
JoshMcCullough Apr 24, 2023
ab74071
use next available port for testing
JoshMcCullough Apr 24, 2023
697551d
fix port casing
JoshMcCullough Apr 24, 2023
b888c93
update to support NGINX 1.23.0+ (#89)
JoshMcCullough Apr 24, 2023
b2ec2bb
rename `auth_jwt_authorization_type` to `auth_jwt_location` and suppo…
JoshMcCullough Apr 25, 2023
da1c7ce
update scripts.sh to add release-related functions
JoshMcCullough Apr 25, 2023
d7a3691
update default NGINX_VERSION to 1.24.0 (stable)
JoshMcCullough Apr 25, 2023
08edb04
Add missing backticks to fix markdown format (#92)
lewisemm Apr 26, 2023
89346e1
fix extraction of claims in nested config block (#91)
JoshMcCullough Apr 26, 2023
f79e660
update make_release to include module version number
JoshMcCullough Apr 26, 2023
d427162
add note about string claims
JoshMcCullough May 3, 2023
a23ed3c
properly set NGINX_VERSION when making releases (#97)
JoshMcCullough May 4, 2023
2eaf11c
fix issue with "Bearer" being removed from header (#106)
JoshMcCullough Aug 10, 2023
294db83
update release versions; test before release
JoshMcCullough Aug 10, 2023
5f9ffd2
GitHub Action to automatically build master branch on commit (#108)
KnownEntity Aug 23, 2023
c843ce1
Update README.md
JoshMcCullough Aug 25, 2023
e5d629e
update CI to only run if src dir is changed
JoshMcCullough Aug 25, 2023
0b8e193
add hex generation to README
JoshMcCullough Aug 25, 2023
05a3798
clarify test logging
JoshMcCullough Oct 13, 2023
2062be5
update scripts.sh to clarify target NGINX versions
JoshMcCullough Dec 4, 2023
07f6f99
replace `sizeof` with `strlen` (#116)
JoshMcCullough Dec 4, 2023
736a95a
update NGINX mainline version
JoshMcCullough Feb 21, 2024
032fa5c
add support for ES algorithms (#118)
swaeberle Mar 18, 2024
03d9553
build custom SSL images; add SSL tests (#126)
JoshMcCullough Mar 19, 2024
02f4e17
case-insenitive Bearer check #134 (#135)
JoshMcCullough Aug 28, 2024
272c02e
fix release script
JoshMcCullough Aug 28, 2024
c5882b0
fix Docker warnings
JoshMcCullough Oct 14, 2024
867562a
fix /tmp dir perms for containers
JoshMcCullough Oct 14, 2024
b93b816
update NGINX versions to build against
JoshMcCullough Oct 14, 2024
e8e60e6
rm redundant `-e`
JoshMcCullough Oct 14, 2024
16b0369
update scripts to support arts
JoshMcCullough Oct 14, 2024
d8974eb
no releases from PRs
JoshMcCullough Feb 4, 2025
27fcd3d
update NGINX versions to build against
JoshMcCullough Feb 4, 2025
576fe71
update workflow action version
JoshMcCullough Feb 4, 2025
d29adbb
rename start/stop script functions
JoshMcCullough Feb 4, 2025
a774c42
rename scripts.sh
JoshMcCullough Feb 4, 2025
7c9cb00
Feature: Add support for ARM64 (#139)
AdrianCarreno Feb 4, 2025
edabc23
support ARM
JoshMcCullough Feb 4, 2025
81a2b44
Support extracting claims to NGINX variables (#145)
wpjunior Feb 4, 2025
5c3d1b9
fix workflow
JoshMcCullough Feb 4, 2025
c38ae69
fix release artifact upload
JoshMcCullough Feb 5, 2025
acbb12e
update redirect URL to include port (#146)
JoshMcCullough Feb 5, 2025
a2e3e91
fix artifact processing in workflow
JoshMcCullough Feb 5, 2025
c415b81
fix incorrect function name
JoshMcCullough Feb 5, 2025
a166241
restore accidentally-deleted test dir :-|
JoshMcCullough Feb 18, 2025
7085f5c
update example config
JoshMcCullough Feb 18, 2025
a110d0c
update NGINX versions to build against
JoshMcCullough Feb 18, 2025
8e4f2af
update array style
JoshMcCullough Feb 18, 2025
df75972
fix script function calls
JoshMcCullough Feb 18, 2025
e019e20
clean up & fix build process
JoshMcCullough Feb 18, 2025
b128954
specify platform / fix spacing
JoshMcCullough Jul 29, 2025
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
43 changes: 43 additions & 0 deletions .bin/git/hooks-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

# Runs all executable pre-commit-* hooks and exits after,
# if any of them was not successful.
#
# Based on
# https://github.com/ELLIOTTCABLE/Paws.js/blob/Master/Scripts/git-hooks/chain-hooks.sh
# http://osdir.com/ml/git/2009-01/msg00308.html
#
# assumes your scripts are located at <repo-root>/bin/git/hooks

exitcodes=()
hookname=`basename $0`
# our special hooks folder
CUSTOM_HOOKS_DIR=$(git rev-parse --show-toplevel)/bin/git/hooks
# find gits native hooks folder
NATIVE_HOOKS_DIR=$(git rev-parse --show-toplevel)/.git/hooks

# Run each hook, passing through STDIN and storing the exit code.
# We don't want to bail at the first failure, as the user might
# then bypass the hooks without knowing about additional issues.

for hook in ${CUSTOM_HOOKS_DIR}/$(basename $0)-*; do
test -x "$hook" || continue

echo "Running custom hook '$hookname' ..."
out=`$hook "$@"`
exitcodes+=($?)
echo "$out"
done

# check if there was a local hook that was moved previously
if [ -f "${NATIVE_HOOKS_DIR}/$hookname.local" ]; then
echo "Running native hook '$hookname' ..."
out=`${NATIVE_HOOKS_DIR}/$hookname.local "$@"`
exitcodes+=($?)
echo "$out"
fi

# If any exit code isn't 0, bail.
for i in "${exitcodes[@]}"; do
[ "$i" == 0 ] || exit $i
done
12 changes: 12 additions & 0 deletions .bin/git/hooks/pre-push-build-and-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

REPO_ROOT_DIR=$(git rev-parse --show-toplevel)
CHANGE_COUNT=$(cd ${REPO_ROOT_DIR}; git diff --name-only origin/HEAD..HEAD -- resources/ src/ test/ Dockerfile scripts.sh |wc -l)

if [[ "0" -ne "${CHANGE_COUNT}" ]]; then
(cd ${REPO_ROOT_DIR}; ./scripts.sh rebuild_nginx rebuild_test test)
else
HOOK_NAME=$(basename $0)

echo "Skipping hook '${HOOK_NAME}' -- no changes detected which would require tests to be run."
fi
19 changes: 19 additions & 0 deletions .bin/git/init-hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# based on http://stackoverflow.com/a/3464399/1383268
# assumes that the hooks-wrapper script is located at <repo-root>/bin/git/hooks-wrapper

HOOK_NAMES="applypatch-msg pre-applypatch post-applypatch pre-commit prepare-commit-msg commit-msg post-commit pre-rebase post-checkout post-merge pre-receive update post-receive post-update pre-auto-gc pre-push"
# find git's native hooks folder
REPO_ROOT_DIR=$(git rev-parse --show-toplevel)
HOOKS_DIR=$(git rev-parse --show-toplevel)/.git/hooks

for hook in ${HOOK_NAMES}; do
# If the hook already exists, is a file, and is not a symlink
if [ ! -h ${HOOKS_DIR}/${hook} ] && [ -f ${HOOKS_DIR}/${hook} ]; then
mv ${HOOKS_DIR}/${hook} ${HOOKS_DIR}/${hook}.local
fi
# create the symlink, overwriting the file if it exists
# probably the only way this would happen is if you're using an old version of git
# -- back when the sample hooks were not executable, instead of being named ____.sample
ln -s -f ${REPO_ROOT_DIR}/bin/git/hooks-wrapper ${HOOKS_DIR}/${hook}
done
3 changes: 3 additions & 0 deletions .bin/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

source $(dirname $0)/git/init-hooks
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=jwt-nginx-test
182 changes: 182 additions & 0 deletions .github/workflows/make-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Make Releases

on:
workflow_dispatch:

jobs:
meta:
name: Get Metadata
runs-on: ubuntu-latest
outputs:
tag: ${{steps.meta.outputs.tag}}
steps:

- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Metadata
id: meta
run: |
set -eu
tag=$(git describe --tags --abbrev=0)

echo "tag=${tag}" >> $GITHUB_OUTPUT

build:
name: "NGINX: ${{ matrix.nginx-version }}; libjwt: ${{ matrix.libjwt-version }}"
needs: meta
strategy:
matrix:
nginx-version:
- 1.20.2 # legacy
- 1.22.1 # legacy
- 1.24.0 # legacy
- 1.26.2 # stable
- 1.26.3 # stable
- 1.27.3 # mainline
- 1.27.4 # mainline

libjwt-version:
- 1.12.0
- 1.14.0
- 1.15.3
runs-on: ubuntu-latest
steps:

- name: Checkout Code
uses: actions/checkout@v4
with:
path: ngx-http-auth-jwt-module

- name: Get Metadata
id: meta
run: |
set -eu
artifact="ngx-http-auth-jwt-module-${{needs.meta.outputs.tag}}_libjwt-${{matrix.libjwt-version}}_nginx-${{matrix.nginx-version}}"

echo "artifact=${artifact}" >> $GITHUB_OUTPUT
echo "filename=${artifact}.tgz" >> $GITHUB_OUTPUT


# TODO cache the build result so we don't have to do this every time?
- name: Download jansson
uses: actions/checkout@v4
with:
repository: 'akheron/jansson'
ref: 'v2.14'
path: 'jansson'

- name: Build jansson
working-directory: ./jansson
run: |
set -e
cmake . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF
make
make check
sudo make install

# TODO cache the build result so we don't have to do this every time?
- name: Download libjwt
uses: actions/checkout@v4
with:
repository: 'benmcollins/libjwt'
ref: 'v${{matrix.libjwt-version}}'
path: 'libjwt'

- name: Build libjwt
working-directory: ./libjwt
run: |
set -e
autoreconf -i
./configure
make all
sudo make install

- name: Download NGINX
run: |
mkdir nginx
curl -O http://nginx.org/download/nginx-${{matrix.nginx-version}}.tar.gz
tar -xzf nginx-${{matrix.nginx-version}}.tar.gz --strip-components 1 -C nginx

- name: Configure NGINX
working-directory: ./nginx
run: |
BUILD_FLAGS=''
MAJ=$(echo ${{matrix.nginx-version}} | cut -f1 -d.)
MIN=$(echo ${{matrix.nginx-version}} | cut -f2 -d.)
REV=$(echo ${{matrix.nginx-version}} | cut -f3 -d.)

if [ "${MAJ}" -gt 1 ] || [ "${MAJ}" -eq 1 -a "${MIN}" -ge 23 ]; then
BUILD_FLAGS="${BUILD_FLAGS} --with-cc-opt='-DNGX_LINKED_LIST_COOKIES=1'"
fi

./configure --with-compat --without-http_rewrite_module --add-dynamic-module=../ngx-http-auth-jwt-module ${BUILD_FLAGS}

- name: Make Modules
working-directory: ./nginx
run: make modules

- name: Create Release Archive
run: |
cp ./nginx/objs/ngx_http_auth_jwt_module.so ./
tar czf ${{steps.meta.outputs.filename}} ngx_http_auth_jwt_module.so

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{steps.meta.outputs.artifact}}
path: ${{steps.meta.outputs.filename}}

release:
name: Create/Update Release
needs:
- meta
- build
runs-on: ubuntu-latest
permissions:
contents: write
steps:

- name: Set-up Variables
id: vars
run: |
echo "date_now=$(date --rfc-3339=seconds)" >> "${GITHUB_OUTPUT}"

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Flatten Artifacts
run: |
set -eu

cd artifacts

for f in $(find . -type f); do
echo "Staging: ${f}"
mv "${f}" .
done

find . -type d -mindepth 1 -exec rm -rf "{}" +

- name: Create/Update Release
uses: ncipollo/release-action@v1
with:
tag: ${{needs.meta.outputs.tag}}
name: "Pre-release: ${{needs.meta.outputs.tag}}"
body: |
> [!WARNING]
> This is an automatically generated pre-release version of the module, which includes the latest master branch changes.
> Please report any bugs you find.

- Build Date: `${{ steps.vars.outputs.date_now }}`
- Commit: `${{ github.sha }}`
prerelease: true
allowUpdates: true
removeArtifacts: true
artifactErrorsFailBuild: true
artifacts: artifacts/*
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.vscode
bin
release
86 changes: 0 additions & 86 deletions Dockerfile

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Tesla Government

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading