diff --git a/.github/actions/install/boost-json/action.yml b/.github/actions/install/boost-json/action.yml index edebb5b7e..61c045969 100644 --- a/.github/actions/install/boost-json/action.yml +++ b/.github/actions/install/boost-json/action.yml @@ -4,9 +4,11 @@ inputs: version: description: The desired Boost.JSON version to install required: false - default: "1.90.0" + default: "1.92.0" runs: using: composite steps: - - run: ${{ github.action_path }}/install-boost-json.sh ${{ inputs.version }} + - run: '"$GITHUB_ACTION_PATH/install-boost-json.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/boost-json/install-boost-json.sh b/.github/actions/install/boost-json/install-boost-json.sh index 66d78a97c..1bdb5dd0a 100755 --- a/.github/actions/install/boost-json/install-boost-json.sh +++ b/.github/actions/install/boost-json/install-boost-json.sh @@ -1,48 +1,19 @@ #!/usr/bin/env bash -# Install Boost.JSON library with specified version - -set -e # Exit on error - -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install Boost.JSON library" - echo "" - echo "Arguments:" - echo " VERSION Boost.JSON version to install (required)" - echo "" - echo "Examples:" - echo " $0 1.90.0" - echo " $0 1.89.0" - exit 1 -fi - -BOOST_JSON_VERSION="$1" -INSTALL_DIR="/tmp" -BUILD_DIR="${INSTALL_DIR}/boost-${BOOST_JSON_VERSION}" - -echo "Installing Boost.JSON v${BOOST_JSON_VERSION}..." - -# Download -echo "Downloading Boost.JSON v${BOOST_JSON_VERSION}..." -cd "${INSTALL_DIR}" -wget -q "https://github.com/boostorg/boost/releases/download/boost-${BOOST_JSON_VERSION}/boost-${BOOST_JSON_VERSION}-cmake.tar.xz" - -# Extract -echo "Extracting archive..." -tar -xf "boost-${BOOST_JSON_VERSION}-cmake.tar.xz" - -# Build and install -echo "Building and installing..." -cd "${BUILD_DIR}" -cmake . -DCMAKE_BUILD_TYPE=Release -DBOOST_INCLUDE_LIBRARIES="json" -cmake --build . --config Release -sudo cmake --install . - -# Cleanup -echo "Cleaning up..." -rm -f "${INSTALL_DIR}/boost-${BOOST_JSON_VERSION}-cmake.tar.xz" -rm -rf "${BUILD_DIR}" - -echo "✓ Boost.JSON v${BOOST_JSON_VERSION} installed successfully!" +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require cmake + +SOURCE_DIR="$INSTALL_WORK_DIR/boost-${INSTALL_VERSION}" +BUILD_DIR="$INSTALL_WORK_DIR/build" +install_download_extract \ + "https://github.com/boostorg/boost/releases/download/boost-${INSTALL_VERSION}/boost-${INSTALL_VERSION}-cmake.tar.xz" \ + "boost-${INSTALL_VERSION}-cmake.tar.xz" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -DBOOST_INCLUDE_LIBRARIES=json -DBUILD_TESTING=OFF +cmake --build "$BUILD_DIR" --config Release --parallel "$INSTALL_JOBS" +cmake --install "$BUILD_DIR" --config Release +install_publish_environment +echo "Boost.JSON ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/common.sh b/.github/actions/install/common.sh new file mode 100644 index 000000000..cafb76527 --- /dev/null +++ b/.github/actions/install/common.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +install_init() { + INSTALL_VERSION="${1:-}" + if [[ "$INSTALL_VERSION" == "-h" || "$INSTALL_VERSION" == "--help" ]]; then + echo "Usage: $0 VERSION [--prefix PATH] [--jobs N]" + exit 0 + fi + if [[ -z "$INSTALL_VERSION" ]]; then + echo "Usage: $0 VERSION [--prefix PATH] [--jobs N]" >&2 + exit 1 + fi + shift + + INSTALL_PREFIX="${JWT_CPP_INSTALL_PREFIX:-$HOME/.local}" + INSTALL_JOBS="${JWT_CPP_INSTALL_JOBS:-2}" + while [[ $# -gt 0 ]]; do + case "$1" in + --prefix) + [[ $# -ge 2 && -n "$2" ]] || { echo "Missing path after --prefix" >&2; return 2; } + INSTALL_PREFIX="$2" + shift 2 + ;; + --jobs) + [[ $# -ge 2 && "$2" =~ ^[1-9][0-9]*$ ]] || { echo "--jobs must be a positive integer" >&2; return 2; } + INSTALL_JOBS="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" >&2 + return 2 + ;; + esac + done + case "$INSTALL_PREFIX" in + *$'\n'*) echo "Install prefix cannot contain a newline" >&2; return 2 ;; + esac + + mkdir -p "$INSTALL_PREFIX" + INSTALL_WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/jwt-cpp-install.XXXXXX")" + trap 'rm -rf "$INSTALL_WORK_DIR"' EXIT +} + +install_require() { + local command + for command in "$@"; do + if ! command -v "$command" >/dev/null 2>&1; then + echo "Required command not found: $command" >&2 + return 1 + fi + done +} + +install_download_extract() { + local url="$1" + local archive="$2" + install_require curl tar + curl --fail --location --retry 3 --silent --show-error "$url" --output "$INSTALL_WORK_DIR/$archive" + tar -xf "$INSTALL_WORK_DIR/$archive" -C "$INSTALL_WORK_DIR" +} + +install_prepend_env() { + local name="$1" + local value="$2" + local current="${!name:-}" + if [[ -n "${GITHUB_ENV:-}" ]]; then + if [[ ":$current:" != *":$value:"* ]]; then + printf '%s=%s\n' "$name" "$value${current:+:$current}" >> "$GITHUB_ENV" + fi + fi +} + +install_set_env() { + local name="$1" + local value="$2" + if [[ -n "${GITHUB_ENV:-}" ]]; then + printf '%s=%s\n' "$name" "$value" >> "$GITHUB_ENV" + fi +} + +install_publish_environment() { + local extra_variable="${1:-}" + local pkgconfig_path="$INSTALL_PREFIX/lib/pkgconfig:$INSTALL_PREFIX/lib64/pkgconfig" + local library_path="$INSTALL_PREFIX/lib:$INSTALL_PREFIX/lib64" + install_prepend_env CMAKE_PREFIX_PATH "$INSTALL_PREFIX" + install_prepend_env PKG_CONFIG_PATH "$pkgconfig_path" + install_prepend_env LD_LIBRARY_PATH "$library_path" + install_prepend_env DYLD_LIBRARY_PATH "$library_path" + if [[ -n "$extra_variable" ]]; then + install_set_env "$extra_variable" "$INSTALL_PREFIX" + fi +} diff --git a/.github/actions/install/danielaparker-jsoncons/action.yml b/.github/actions/install/danielaparker-jsoncons/action.yml index e29bbd004..c5520d5fb 100644 --- a/.github/actions/install/danielaparker-jsoncons/action.yml +++ b/.github/actions/install/danielaparker-jsoncons/action.yml @@ -4,9 +4,11 @@ inputs: version: description: The desired jsoncons version to install required: false - default: "1.3.2" + default: "1.10.0" runs: using: composite steps: - - run: ${{ github.action_path }}/install-jsoncons.sh ${{ inputs.version }} + - run: '"$GITHUB_ACTION_PATH/install-jsoncons.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/danielaparker-jsoncons/install-jsoncons.sh b/.github/actions/install/danielaparker-jsoncons/install-jsoncons.sh index 18bf37dc7..1b88b70c2 100755 --- a/.github/actions/install/danielaparker-jsoncons/install-jsoncons.sh +++ b/.github/actions/install/danielaparker-jsoncons/install-jsoncons.sh @@ -1,49 +1,18 @@ #!/usr/bin/env bash -# Install jsoncons library with specified version - -set -e # Exit on error - -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install jsoncons library" - echo "" - echo "Arguments:" - echo " VERSION jsoncons version to install (required)" - echo "" - echo "Examples:" - echo " $0 1.5.0" - echo " $0 1.4.3" - echo " $0 1.3.2" - exit 1 -fi - -# Configuration -JSONCONS_VERSION="$1" -INSTALL_DIR="/tmp" -BUILD_DIR="${INSTALL_DIR}/jsoncons-${JSONCONS_VERSION}" - -echo "Installing jsoncons v${JSONCONS_VERSION}..." - -# Download -echo "Downloading jsoncons v${JSONCONS_VERSION}..." -cd "${INSTALL_DIR}" -wget -q "https://github.com/danielaparker/jsoncons/archive/v${JSONCONS_VERSION}.tar.gz" - -# Extract -echo "Extracting archive..." -tar -zxf "v${JSONCONS_VERSION}.tar.gz" - -# Build and install -echo "Building and installing..." -cd "${BUILD_DIR}" -cmake . -DCMAKE_BUILD_TYPE=Release -sudo cmake --install . - -# Cleanup -echo "Cleaning up..." -rm -f "${INSTALL_DIR}/v${JSONCONS_VERSION}.tar.gz" -rm -rf "${BUILD_DIR}" - -echo "✓ jsoncons v${JSONCONS_VERSION} installed successfully!" +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require cmake + +SOURCE_DIR="$INSTALL_WORK_DIR/jsoncons-${INSTALL_VERSION}" +BUILD_DIR="$INSTALL_WORK_DIR/build" +install_download_extract "https://github.com/danielaparker/jsoncons/archive/v${INSTALL_VERSION}.tar.gz" \ + "jsoncons-${INSTALL_VERSION}.tar.gz" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \ + -DJSONCONS_BUILD_TESTS=OFF +cmake --build "$BUILD_DIR" --parallel "$INSTALL_JOBS" +cmake --install "$BUILD_DIR" +install_publish_environment +echo "jsoncons ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/glaze-json/action.yml b/.github/actions/install/glaze-json/action.yml index c88bad295..8823ce801 100644 --- a/.github/actions/install/glaze-json/action.yml +++ b/.github/actions/install/glaze-json/action.yml @@ -4,9 +4,11 @@ inputs: version: description: The desired Glaze version to install required: false - default: "7.0.2" + default: "9.1.0" runs: using: composite steps: - - run: ${{ github.action_path }}/install-glaze.sh ${{ inputs.version }} + - run: '"$GITHUB_ACTION_PATH/install-glaze.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/glaze-json/install-glaze.sh b/.github/actions/install/glaze-json/install-glaze.sh index 95b419a61..cb38731d9 100755 --- a/.github/actions/install/glaze-json/install-glaze.sh +++ b/.github/actions/install/glaze-json/install-glaze.sh @@ -1,49 +1,18 @@ #!/usr/bin/env bash -# Install glaze library with specified version - -set -e # Exit on error - -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install glaze library" - echo "" - echo "Arguments:" - echo " VERSION glaze version to install (required)" - echo "" - echo "Examples:" - echo " $0 7.0.2" - exit 1 -fi - -# Configuration -glaze_VERSION="$1" -INSTALL_DIR="/tmp" -BUILD_DIR="${INSTALL_DIR}/glaze-${glaze_VERSION}" - -echo "Installing glaze v${glaze_VERSION}..." - -# Download -echo "Downloading glaze v${glaze_VERSION}..." -cd "${INSTALL_DIR}" -wget -q "https://github.com/stephenberry/glaze/archive/v${glaze_VERSION}.tar.gz" - -# Extract -echo "Extracting archive..." -tar -zxf "v${glaze_VERSION}.tar.gz" - -# Build and install -echo "Building and installing..." -cd "${BUILD_DIR}" -mkdir -p build -cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -sudo cmake --install . - -# Cleanup -echo "Cleaning up..." -rm -f "${INSTALL_DIR}/v${glaze_VERSION}.tar.gz" -rm -rf "${BUILD_DIR}" - -echo "✓ glaze v${glaze_VERSION} installed successfully!" +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require cmake + +SOURCE_DIR="$INSTALL_WORK_DIR/glaze-${INSTALL_VERSION}" +BUILD_DIR="$INSTALL_WORK_DIR/build" +install_download_extract "https://github.com/stephenberry/glaze/archive/v${INSTALL_VERSION}.tar.gz" \ + "glaze-${INSTALL_VERSION}.tar.gz" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \ + -Dglaze_DEVELOPER_MODE=OFF +cmake --build "$BUILD_DIR" --parallel "$INSTALL_JOBS" +cmake --install "$BUILD_DIR" +install_publish_environment +echo "Glaze ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/gtest/action.yml b/.github/actions/install/gtest/action.yml index 7211bb223..ee5396bb5 100644 --- a/.github/actions/install/gtest/action.yml +++ b/.github/actions/install/gtest/action.yml @@ -8,5 +8,7 @@ inputs: runs: using: composite steps: - - run: ${{ github.action_path }}/install-gtest.sh ${{ inputs.version }} + - run: '"$GITHUB_ACTION_PATH/install-gtest.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/gtest/install-gtest.sh b/.github/actions/install/gtest/install-gtest.sh index 7ab50454e..d3fc23060 100755 --- a/.github/actions/install/gtest/install-gtest.sh +++ b/.github/actions/install/gtest/install-gtest.sh @@ -1,48 +1,20 @@ #!/usr/bin/env bash -# Install gtest library with specified version - -set -e # Exit on error - -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install gtest library" - echo "" - echo "Arguments:" - echo " VERSION gtest version to install (required)" - echo "" - echo "Examples:" - echo " $0 1.17.0" - exit 1 -fi - -# Configuration -gtest_VERSION="$1" -INSTALL_DIR="/tmp" -BUILD_DIR="${INSTALL_DIR}/googletest-${gtest_VERSION}" - -echo "Installing gtest v${gtest_VERSION}..." - -# Download -echo "Downloading gtest v${gtest_VERSION}..." -cd "${INSTALL_DIR}" -wget -q "https://github.com/google/googletest/releases/download/v${gtest_VERSION}/googletest-${gtest_VERSION}.tar.gz" - -# Extract -echo "Extracting archive..." -tar -zxf "googletest-${gtest_VERSION}.tar.gz" - -# Build and install -echo "Building and installing..." -cd "${BUILD_DIR}" -cmake . -DCMAKE_BUILD_TYPE=Release -DINSTALL_GTEST=ON -cmake --build . -sudo make install # There's a bug in the v1.16.0 CMakeLists.txt that doesn't properly install the library when invoked via CMake, so we have to use make install directly - -# Cleanup -echo "Cleaning up..." -rm -f "${INSTALL_DIR}/googletest-${gtest_VERSION}.tar.gz" -rm -rf "${BUILD_DIR}" - -echo "✓ gtest v${gtest_VERSION} installed successfully!" +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require cmake make + +SOURCE_DIR="$INSTALL_WORK_DIR/googletest-${INSTALL_VERSION}" +BUILD_DIR="$INSTALL_WORK_DIR/build" +install_download_extract \ + "https://github.com/google/googletest/releases/download/v${INSTALL_VERSION}/googletest-${INSTALL_VERSION}.tar.gz" \ + "googletest-${INSTALL_VERSION}.tar.gz" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DINSTALL_GTEST=ON \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" +cmake --build "$BUILD_DIR" --parallel "$INSTALL_JOBS" +# Use make install because the CMake install target is broken in GTest 1.16.0. +make -C "$BUILD_DIR" -j "$INSTALL_JOBS" install +install_publish_environment +echo "GoogleTest ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/kazuho-picojson/action.yml b/.github/actions/install/kazuho-picojson/action.yml index caf887512..65fc1f3ae 100644 --- a/.github/actions/install/kazuho-picojson/action.yml +++ b/.github/actions/install/kazuho-picojson/action.yml @@ -8,10 +8,7 @@ inputs: runs: using: composite steps: - - run: | - cd /tmp - wget https://github.com/kazuho/picojson/archive/${{ inputs.version }}.tar.gz - tar -zxf /tmp/${{ inputs.version }}.tar.gz - cd picojson-${{ inputs.version }} - sudo cp -v picojson.h /usr/local/include/picojson + - run: '"$GITHUB_ACTION_PATH/install-picojson.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/kazuho-picojson/install-picojson.sh b/.github/actions/install/kazuho-picojson/install-picojson.sh new file mode 100755 index 000000000..f8c8282fb --- /dev/null +++ b/.github/actions/install/kazuho-picojson/install-picojson.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" + +ARCHIVE_VERSION="${INSTALL_VERSION#v}" +SOURCE_DIR="$INSTALL_WORK_DIR/picojson-${ARCHIVE_VERSION}" +install_download_extract "https://github.com/kazuho/picojson/archive/${INSTALL_VERSION}.tar.gz" \ + "picojson-${ARCHIVE_VERSION}.tar.gz" +mkdir -p "$INSTALL_PREFIX/include/picojson" +cp "$SOURCE_DIR/picojson.h" "$INSTALL_PREFIX/include/picojson/picojson.h" +install_publish_environment +echo "picojson ${ARCHIVE_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/libressl/action.yml b/.github/actions/install/libressl/action.yml index 55cdc4c0f..29db0ae1f 100644 --- a/.github/actions/install/libressl/action.yml +++ b/.github/actions/install/libressl/action.yml @@ -4,9 +4,11 @@ inputs: version: description: The desired LibreSSL version to install required: false - default: "4.2.1" + default: "4.4.1" runs: using: composite steps: - - run: ${{ github.action_path }}/install-libressl.sh ${{ inputs.version }} + - run: '"$GITHUB_ACTION_PATH/install-libressl.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/libressl/install-libressl.sh b/.github/actions/install/libressl/install-libressl.sh index e95bfa8f8..865681867 100755 --- a/.github/actions/install/libressl/install-libressl.sh +++ b/.github/actions/install/libressl/install-libressl.sh @@ -1,30 +1,26 @@ #!/usr/bin/env bash -# Install LibreSSL library with specified version +set -euo pipefail -set -e # Exit on error +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require make -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install libreSSL library" - echo "" - echo "Arguments:" - echo " VERSION libreSSL version to install (required)" - echo "" - echo "Examples:" - echo " $0 4.2.1" - echo " $0 4.1.2" - echo " $0 3.9.4" - exit 1 -fi +SOURCE_DIR="$INSTALL_WORK_DIR/libressl-${INSTALL_VERSION}" +install_download_extract \ + "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${INSTALL_VERSION}.tar.gz" \ + "libressl-${INSTALL_VERSION}.tar.gz" +( + cd "$SOURCE_DIR" + ./configure --prefix="$INSTALL_PREFIX" + make -j "$INSTALL_JOBS" + make install +) -LIBRESSL_VERSION="$1" +mkdir -p "$INSTALL_PREFIX/cmake" +curl --fail --location --retry 3 --silent --show-error \ + "https://raw.githubusercontent.com/libressl-portable/portable/v${INSTALL_VERSION}/FindLibreSSL.cmake" \ + --output "$INSTALL_PREFIX/cmake/FindLibreSSL.cmake" -wget https://raw.githubusercontent.com/libressl-portable/portable/v${LIBRESSL_VERSION}/FindLibreSSL.cmake -P cmake/ -cd /tmp -wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz -tar -zvxf /tmp/libressl-${LIBRESSL_VERSION}.tar.gz -cd libressl-${LIBRESSL_VERSION} -./configure -sudo make -j $(nproc) install +install_publish_environment LIBRESSL_ROOT_DIR +echo "LibreSSL ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/nlohmann-json/action.yml b/.github/actions/install/nlohmann-json/action.yml index 80124924d..918aa1e3b 100644 --- a/.github/actions/install/nlohmann-json/action.yml +++ b/.github/actions/install/nlohmann-json/action.yml @@ -8,11 +8,7 @@ inputs: runs: using: composite steps: - - run: | - cd /tmp - wget https://github.com/nlohmann/json/archive/v${{ inputs.version }}.tar.gz - tar -zxf /tmp/v${{ inputs.version }}.tar.gz - cd json-${{ inputs.version }} - cmake . - sudo cmake --install . + - run: '"$GITHUB_ACTION_PATH/install-nlohmann-json.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/nlohmann-json/install-nlohmann-json.sh b/.github/actions/install/nlohmann-json/install-nlohmann-json.sh new file mode 100755 index 000000000..a8e3dad91 --- /dev/null +++ b/.github/actions/install/nlohmann-json/install-nlohmann-json.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require cmake + +SOURCE_DIR="$INSTALL_WORK_DIR/json-${INSTALL_VERSION}" +BUILD_DIR="$INSTALL_WORK_DIR/build" +install_download_extract "https://github.com/nlohmann/json/archive/v${INSTALL_VERSION}.tar.gz" \ + "nlohmann-json-${INSTALL_VERSION}.tar.gz" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \ + -DJSON_BuildTests=OFF +cmake --build "$BUILD_DIR" --parallel "$INSTALL_JOBS" +cmake --install "$BUILD_DIR" +install_publish_environment +echo "nlohmann-json ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/open-source-parsers-jsoncpp/action.yml b/.github/actions/install/open-source-parsers-jsoncpp/action.yml index 34e0692b4..ef3f04a71 100644 --- a/.github/actions/install/open-source-parsers-jsoncpp/action.yml +++ b/.github/actions/install/open-source-parsers-jsoncpp/action.yml @@ -4,9 +4,11 @@ inputs: version: description: The desired open-source-parsers/jsoncpp version to install required: false - default: "1.9.6" + default: "1.9.8" runs: using: composite steps: - - run: ${{ github.action_path }}/install-jsoncpp.sh ${{ inputs.version }} + - run: '"$GITHUB_ACTION_PATH/install-jsoncpp.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/open-source-parsers-jsoncpp/install-jsoncpp.sh b/.github/actions/install/open-source-parsers-jsoncpp/install-jsoncpp.sh index 13838a5a7..f3ad292d3 100755 --- a/.github/actions/install/open-source-parsers-jsoncpp/install-jsoncpp.sh +++ b/.github/actions/install/open-source-parsers-jsoncpp/install-jsoncpp.sh @@ -1,51 +1,18 @@ #!/usr/bin/env bash -# Install jsoncpp library with specified version - -set -e # Exit on error - -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install jsoncpp library" - echo "" - echo "Arguments:" - echo " VERSION jsoncpp version to install (required)" - echo "" - echo "Examples:" - echo " $0 1.9.6" - exit 1 -fi - -# Configuration -JSONCPP_VERSION="$1" -INSTALL_DIR="/tmp" -BUILD_DIR="${INSTALL_DIR}/jsoncpp-${JSONCPP_VERSION}" - -echo "Installing jsoncpp v${JSONCPP_VERSION}..." - -# Download -echo "Downloading jsoncpp v${JSONCPP_VERSION}..." -cd "${INSTALL_DIR}" -wget -q "https://github.com/open-source-parsers/jsoncpp/archive/${JSONCPP_VERSION}.tar.gz" - -# Extract -echo "Extracting archive..." -tar -zxf "${JSONCPP_VERSION}.tar.gz" - -# Build and install -echo "Building and installing..." -cd "${BUILD_DIR}" -# https://github.com/open-source-parsers/jsoncpp/blob/69098a18b9af0c47549d9a271c054d13ca92b006/include/PreventInSourceBuilds.cmake#L8 -mkdir -p build -cd build -cmake .. -DJSONCPP_WITH_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_OBJECT_LIBS=OFF -cmake --build . -sudo cmake --install . - -# Cleanup -echo "Cleaning up..." -rm -f "${INSTALL_DIR}/${JSONCPP_VERSION}.tar.gz" -rm -rf "${BUILD_DIR}" - -echo "✓ jsoncpp v${JSONCPP_VERSION} installed successfully!" +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require cmake + +SOURCE_DIR="$INSTALL_WORK_DIR/jsoncpp-${INSTALL_VERSION}" +BUILD_DIR="$INSTALL_WORK_DIR/build" +install_download_extract "https://github.com/open-source-parsers/jsoncpp/archive/${INSTALL_VERSION}.tar.gz" \ + "jsoncpp-${INSTALL_VERSION}.tar.gz" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -DJSONCPP_WITH_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_OBJECT_LIBS=OFF +cmake --build "$BUILD_DIR" --parallel "$INSTALL_JOBS" +cmake --install "$BUILD_DIR" +install_publish_environment +echo "JsonCpp ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/openssl/action.yml b/.github/actions/install/openssl/action.yml index 83c03a29e..a93728b4f 100644 --- a/.github/actions/install/openssl/action.yml +++ b/.github/actions/install/openssl/action.yml @@ -4,18 +4,11 @@ inputs: version: description: The desired OpenSSL version to install required: false - default: "openssl-3.0.0" + default: "openssl-4.1.0" runs: using: composite steps: - - run: | - cd /tmp - wget https://github.com/openssl/openssl/archive/refs/tags/${{ inputs.version }}.tar.gz - tar -zxf /tmp/${{ inputs.version }}.tar.gz - cd openssl-${{ inputs.version }} - ./config --prefix=/tmp --libdir=lib - make -j $(nproc) - sudo make -j $(nproc) install_sw - echo "OPENSSL_ROOT_DIR=/tmp" >> "$GITHUB_ENV" - echo "OpenSSL_ROOT=/tmp" >> "$GITHUB_ENV" + - run: '"$GITHUB_ACTION_PATH/install-openssl.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/openssl/install-openssl.sh b/.github/actions/install/openssl/install-openssl.sh new file mode 100755 index 000000000..9d67e379a --- /dev/null +++ b/.github/actions/install/openssl/install-openssl.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require perl make + +SOURCE_DIR="$INSTALL_WORK_DIR/openssl-${INSTALL_VERSION}" +install_download_extract "https://github.com/openssl/openssl/archive/refs/tags/${INSTALL_VERSION}.tar.gz" \ + "openssl-${INSTALL_VERSION}.tar.gz" +( + cd "$SOURCE_DIR" + ./config --prefix="$INSTALL_PREFIX" --libdir=lib + make -j "$INSTALL_JOBS" + make install_sw +) +install_publish_environment OPENSSL_ROOT_DIR +echo "OpenSSL ${INSTALL_VERSION#openssl-} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/reflectcpp-json/action.yml b/.github/actions/install/reflectcpp-json/action.yml index 0853cbf9c..5981dc1f6 100644 --- a/.github/actions/install/reflectcpp-json/action.yml +++ b/.github/actions/install/reflectcpp-json/action.yml @@ -4,9 +4,11 @@ inputs: version: description: The desired reflect-cpp version to install required: false - default: "0.24.0" + default: "0.27.1" runs: using: composite steps: - - run: ${{ github.action_path }}/install-reflect-cpp.sh ${{ inputs.version }} + - run: '"$GITHUB_ACTION_PATH/install-reflect-cpp.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/reflectcpp-json/install-reflect-cpp.sh b/.github/actions/install/reflectcpp-json/install-reflect-cpp.sh index 6793920a9..cdf789223 100755 --- a/.github/actions/install/reflectcpp-json/install-reflect-cpp.sh +++ b/.github/actions/install/reflectcpp-json/install-reflect-cpp.sh @@ -1,48 +1,18 @@ #!/usr/bin/env bash -# Install reflect-cpp library with specified version - -set -e # Exit on error - -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install reflect-cpp library" - echo "" - echo "Arguments:" - echo " VERSION reflect-cpp version to install (required)" - echo "" - echo "Examples:" - echo " $0 0.24.0" - exit 1 -fi - -# Configuration -reflectcpp_VERSION="$1" -INSTALL_DIR="/tmp" -BUILD_DIR="${INSTALL_DIR}/reflect-cpp-${reflectcpp_VERSION}" - -echo "Installing reflectcpp v${reflectcpp_VERSION}..." - -# Download -echo "Downloading reflectcpp v${reflectcpp_VERSION}..." -cd "${INSTALL_DIR}" -wget -q "https://github.com/getml/reflect-cpp/archive/v${reflectcpp_VERSION}.tar.gz" - -# Extract -echo "Extracting archive..." -tar -zxf "v${reflectcpp_VERSION}.tar.gz" - -# Build and install -echo "Building and installing..." -cd "${BUILD_DIR}" -cmake . -DCMAKE_BUILD_TYPE=Release -DREFLECTCPP_INSTALL=ON -cmake --build . -sudo cmake --install . - -# Cleanup -echo "Cleaning up..." -rm -f "${INSTALL_DIR}/v${reflectcpp_VERSION}.tar.gz" -rm -rf "${BUILD_DIR}" - -echo "✓ reflect-cpp v${reflectcpp_VERSION} installed successfully!" +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require cmake + +SOURCE_DIR="$INSTALL_WORK_DIR/reflect-cpp-${INSTALL_VERSION}" +BUILD_DIR="$INSTALL_WORK_DIR/build" +install_download_extract "https://github.com/getml/reflect-cpp/archive/v${INSTALL_VERSION}.tar.gz" \ + "reflect-cpp-${INSTALL_VERSION}.tar.gz" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -DREFLECTCPP_INSTALL=ON +cmake --build "$BUILD_DIR" --parallel "$INSTALL_JOBS" +cmake --install "$BUILD_DIR" +install_publish_environment +echo "reflect-cpp ${INSTALL_VERSION} installed under ${INSTALL_PREFIX}" diff --git a/.github/actions/install/wolfssl/action.yml b/.github/actions/install/wolfssl/action.yml index 013cdb98e..a7dac6cb8 100644 --- a/.github/actions/install/wolfssl/action.yml +++ b/.github/actions/install/wolfssl/action.yml @@ -4,11 +4,11 @@ inputs: version: description: The desired stable wolfSSL version to install required: false - default: "v4.8.1-stable" + default: "v5.9.4-stable" runs: using: composite steps: - - run: ${{ github.action_path }}/install-wolfssl.sh ${{ inputs.version }} - shell: bash - - run: sudo rm -rf /usr/include/openssl + - run: '"$GITHUB_ACTION_PATH/install-wolfssl.sh" "$VERSION" --prefix "$RUNNER_TEMP/jwt-cpp-deps" --jobs "$(nproc)"' shell: bash + env: + VERSION: ${{ inputs.version }} diff --git a/.github/actions/install/wolfssl/install-wolfssl.sh b/.github/actions/install/wolfssl/install-wolfssl.sh index 845ae2421..3ba411db9 100755 --- a/.github/actions/install/wolfssl/install-wolfssl.sh +++ b/.github/actions/install/wolfssl/install-wolfssl.sh @@ -1,31 +1,21 @@ #!/usr/bin/env bash -# Install wolfSSL library with specified version +set -euo pipefail -set -e # Exit on error +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/../common.sh" +install_init "$@" +install_require autoconf automake aclocal autoreconf make -# Check if version is provided -if [[ -z "$1" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then - echo "Usage: $0 VERSION" - echo "" - echo "Install wolfSSL library" - echo "" - echo "Arguments:" - echo " VERSION wolfSSL version to install (required)" - echo "" - echo "Examples:" - echo " $0 4.2.1" - echo " $0 4.1.2" - echo " $0 3.9.4" - exit 1 -fi - -WOLFSSL_VERSION="$1" - -cd /tmp -wget -O wolfssl.tar.gz https://github.com/wolfSSL/wolfssl/archive/$WOLFSSL_VERSION.tar.gz -tar -zxf /tmp/wolfssl.tar.gz -cd wolfssl-* -autoreconf -fiv -./configure --enable-opensslall --enable-opensslextra --disable-examples --disable-crypttests --enable-harden --enable-all --enable-all-crypto -make -sudo make install +SOURCE_DIR="$INSTALL_WORK_DIR/wolfssl-${INSTALL_VERSION#v}" +install_download_extract "https://github.com/wolfSSL/wolfssl/archive/${INSTALL_VERSION}.tar.gz" \ + "wolfssl-${INSTALL_VERSION}.tar.gz" +( + cd "$SOURCE_DIR" + autoreconf -fiv + ./configure --prefix="$INSTALL_PREFIX" --enable-opensslall --enable-opensslextra \ + --disable-examples --disable-crypttests --enable-harden --enable-all --enable-all-crypto + make -j "$INSTALL_JOBS" + make install +) +install_publish_environment +echo "wolfSSL ${INSTALL_VERSION#v} installed under ${INSTALL_PREFIX}" diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b132ca960..98e41fde4 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -225,13 +225,17 @@ jobs: run: | mkdir build cd build - cmake .. -DJWT_SSL_LIBRARY:STRING="LibreSSL" -DJWT_BUILD_EXAMPLES=OFF - sudo make install + cmake .. -DJWT_SSL_LIBRARY:STRING="LibreSSL" -DJWT_BUILD_EXAMPLES=OFF \ + -DCMAKE_INSTALL_PREFIX="$RUNNER_TEMP/jwt-cpp-deps" \ + -DCMAKE_MODULE_PATH="$RUNNER_TEMP/jwt-cpp-deps/cmake" + cmake --build . + cmake --install . - name: test run: | cd tests/cmake - cmake . -DCMAKE_PREFIX_PATH=/usr/local/cmake -DCMAKE_MODULE_PATH=../../cmake -DTEST:STRING="libressl-is-used" + cmake . -DCMAKE_PREFIX_PATH="$RUNNER_TEMP/jwt-cpp-deps/cmake" \ + -DCMAKE_MODULE_PATH="$RUNNER_TEMP/jwt-cpp-deps/cmake" -DTEST:STRING="libressl-is-used" cmake --build . with-wolfssl: diff --git a/.github/workflows/jwt.yml b/.github/workflows/jwt.yml index f34c2d6cd..706b90def 100644 --- a/.github/workflows/jwt.yml +++ b/.github/workflows/jwt.yml @@ -54,7 +54,8 @@ jobs: fail-fast: false matrix: openssl: - - { tag: "openssl-3.6.1", name: "3.6.1" } + - { tag: "openssl-4.1.0", name: "4.1.0" } + - { tag: "openssl-3.5.5", name: "3.5.5" } - { tag: "OpenSSL_1_1_1w", name: "1.1.1w" } steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ssl.yml b/.github/workflows/ssl.yml index 580e3b980..5c28b030f 100644 --- a/.github/workflows/ssl.yml +++ b/.github/workflows/ssl.yml @@ -12,6 +12,7 @@ jobs: strategy: matrix: openssl: + - { tag: "openssl-4.1.0", name: "4.1.0" } - { tag: "openssl-3.0.19", name: "3.0.19" } - { tag: "openssl-3.5.5", name: "3.5.5" } - { tag: "openssl-3.6.1", name: "3.6.1" } @@ -28,6 +29,12 @@ jobs: with: version: ${{ matrix.openssl.tag }} + - name: verify OpenSSL installation + run: | + "$OPENSSL_ROOT_DIR/bin/openssl" version | grep -F "${{ matrix.openssl.name }}" + - name: verify installers left checkout clean + run: git status --short --untracked-files=all && test -z "$(git status --porcelain --untracked-files=all)" + - run: cmake --workflow --preset unit-tests - if: github.event_name == 'push' && always() @@ -38,14 +45,20 @@ jobs: openssl-no-deprecated: runs-on: ubuntu-latest - name: OpenSSL 3.6 No Deprecated + name: OpenSSL 4.1 No Deprecated steps: - uses: actions/checkout@v4 - uses: lukka/get-cmake@latest - uses: ./.github/actions/install/gtest - uses: ./.github/actions/install/openssl with: - version: "openssl-3.6.1" + version: "openssl-4.1.0" + + - name: verify OpenSSL installation + run: | + "$OPENSSL_ROOT_DIR/bin/openssl" version | grep -F "4.1.0" + - name: verify installers left checkout clean + run: git status --short --untracked-files=all && test -z "$(git status --porcelain --untracked-files=all)" - name: configure run: cmake --preset unit-tests -DCMAKE_CXX_FLAGS="-DOPENSSL_NO_DEPRECATED=1" -DCMAKE_C_FLAGS="-DOPENSSL_NO_DEPRECATED=1" @@ -58,7 +71,7 @@ jobs: strategy: fail-fast: false matrix: - libressl: ["4.2.1", "4.1.2", "3.9.2"] + libressl: ["4.4.1", "4.2.1", "3.9.2"] name: LibreSSL ${{ matrix.libressl }} steps: - uses: actions/checkout@v4 @@ -68,8 +81,14 @@ jobs: with: version: ${{ matrix.libressl }} + - name: verify LibreSSL installation + run: | + "$LIBRESSL_ROOT_DIR/bin/openssl" version | grep -F "LibreSSL ${{ matrix.libressl }}" + - name: verify installers left checkout clean + run: git status --short --untracked-files=all && test -z "$(git status --porcelain --untracked-files=all)" + - name: configure - run: cmake --preset unit-tests -DJWT_SSL_LIBRARY:STRING=LibreSSL + run: cmake --preset unit-tests -DJWT_SSL_LIBRARY:STRING=LibreSSL -DCMAKE_MODULE_PATH="$RUNNER_TEMP/jwt-cpp-deps/cmake" - run: cmake --build --preset unit-tests - name: test run: ctest --preset unit-tests --output-on-failure @@ -85,10 +104,9 @@ jobs: strategy: matrix: wolfssl: - - { ref: "v5.1.1-stable", name: "5.1.1"} - - { ref: "v5.2.0-stable", name: "5.2.0" } - - { ref: "v5.3.0-stable", name: "5.3.0"} + - { ref: "v5.9.4-stable", name: "5.9.4"} - { ref: "v5.7.0-stable", name: "5.7.0"} + - { ref: "v5.3.0-stable", name: "5.3.0"} name: wolfSSL ${{ matrix.wolfssl.name }} steps: - uses: actions/checkout@v4 @@ -98,6 +116,12 @@ jobs: with: version: ${{ matrix.wolfssl.ref }} + - name: verify wolfSSL installation + run: | + "$RUNNER_TEMP/jwt-cpp-deps/bin/wolfssl-config" --version | grep -Fx "${{ matrix.wolfssl.name }}" + - name: verify installers left checkout clean + run: git status --short --untracked-files=all && test -z "$(git status --porcelain --untracked-files=all)" + - name: configure run: cmake --preset unit-tests -DJWT_SSL_LIBRARY:STRING=wolfSSL - run: cmake --build --preset unit-tests diff --git a/.github/workflows/traits.yml b/.github/workflows/traits.yml index c1866b061..054fb1f00 100644 --- a/.github/workflows/traits.yml +++ b/.github/workflows/traits.yml @@ -16,22 +16,20 @@ jobs: strategy: matrix: target: - - { name: "danielaparker-jsoncons", tag: "1.3.2", version: "v1.3.2" } - - { name: "boost-json", tag: "1.90.0", version: "v1.90.0" } + - { name: "danielaparker-jsoncons", tag: "1.10.0", version: "v1.10.0" } + - { name: "boost-json", tag: "1.92.0", version: "v1.92.0" } - { name: "nlohmann-json", tag: "3.12.0", version: "v3.12.0" } - { name: "kazuho-picojson", tag: "111c9be5188f7350c2eac9ddaedd8cca3d7bf394", version: "111c9be" } - - { name: "open-source-parsers-jsoncpp", tag: "1.9.6", version: "v1.9.6" } - - { name: "glaze-json", tag: "7.0.2", version: "v7.0.2" } - - { name: "reflectcpp-json", tag: "0.24.0", version: "v0.24.0" } + - { name: "open-source-parsers-jsoncpp", tag: "1.9.8", version: "v1.9.8" } + - { name: "glaze-json", tag: "9.1.0", version: "v9.1.0" } + - { name: "reflectcpp-json", tag: "0.27.1", version: "v0.27.1" } steps: - uses: actions/checkout@v4 - uses: lukka/get-cmake@latest - name: setup run: | - mkdir build - cd build - cmake .. -DJWT_BUILD_EXAMPLES=OFF - sudo cmake --install . + cmake -S . -B build -DJWT_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX="$RUNNER_TEMP/jwt-cpp-deps" + cmake --install build # Install the JSON library - if: matrix.target.name == 'danielaparker-jsoncons' @@ -49,6 +47,7 @@ jobs: with: version: ${{matrix.target.tag}} + # Delete the vendor directory for kazuho-picojson to ensure that the install action is used. - if: matrix.target.name == 'kazuho-picojson' run: rm -rf include/picojson - if: matrix.target.name == 'kazuho-picojson' @@ -71,10 +70,14 @@ jobs: with: version: ${{ matrix.target.tag }} + - if: matrix.target.name != 'kazuho-picojson' + name: verify installers left checkout clean + run: git status --short --untracked-files=all && test -z "$(git status --porcelain --untracked-files=all)" + - name: test working-directory: example/traits run: | - cmake . -DCMAKE_FIND_DEBUG_MODE=1 + cmake . -DCMAKE_FIND_DEBUG_MODE=1 -DCMAKE_CXX_FLAGS="-DJSONCONS_NO_DEPRECATED" cmake --build . --target ${{ matrix.target.name }} ./${{ matrix.target.name }} diff --git a/docs/ssl.md b/docs/ssl.md index f6b9fa834..5e1434f82 100644 --- a/docs/ssl.md +++ b/docs/ssl.md @@ -18,32 +18,27 @@ These are the versions which are currently being tested: | OpenSSL | LibreSSL | wolfSSL | | --------------------- | ------------------ | -------------- | -| ![3.0.19][o3.0] | ![4.2.1][l4.2] | ![5.1.1][w5.1] | -| ![3.5.5][o3.5] :star: | ![4.1.2][l4.1] | ![5.2.0][w5.2] | -| ![3.6.1][o3.6] | ![3.9.2][l3.9] | ![5.3.0][w5.3] | -| ![1.1.1w][o1.1.1] | | | -| ![1.0.2u][o1.0.2] | | | +| ![4.1.0][o4.1] | ![4.4.1][l4.4] | ![5.9.4][w5.9] | +| ![3.5.5][o3.5] :star: | ![4.2.1][l4.2] | ![5.7.0][w5.7] | +| ![3.0.19][o3.0] | ![3.9.2][l3.9] | ![5.3.0][w5.3] | > [!NOTE] > :star: Indicates LTS (Long-Term Support) versions. [OpenSSL versions](https://openssl-library.org/policies/releasestrat/index.html) are supported as follows: > -> - **3.0.19**: Supported until 2026-09-07 (LTS) > - **3.5.5**: Supported until 2030-04-08 (LTS) -> - **3.6.1**: Supported until 2026-11-01 +> - **4.1.0**: Supported until 2027-11-23 > > A complete list of versions tested in the past can be found [on this branch](https://github.com/Thalhammer/jwt-cpp/tree/badges). -[o1.0.2]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/1.0.2u/shields.json -[o1.1.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/1.1.1w/shields.json [o3.0]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/3.0.19/shields.json [o3.5]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/3.5.5/shields.json -[o3.6]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/3.6.1/shields.json +[o4.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/4.1.0/shields.json +[l4.4]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/4.4.1/shields.json [l4.2]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/4.2.1/shields.json -[l4.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/4.1.2/shields.json [l3.9]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.9.2/shields.json -[w5.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.1.1/shields.json -[w5.2]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.2.0/shields.json [w5.3]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.3.0/shields.json +[w5.7]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.7.0/shields.json +[w5.9]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.9.4/shields.json ## Notes diff --git a/include/jwt-cpp/traits/danielaparker-jsoncons/traits.h b/include/jwt-cpp/traits/danielaparker-jsoncons/traits.h index bb00d5418..7bcb05bae 100644 --- a/include/jwt-cpp/traits/danielaparker-jsoncons/traits.h +++ b/include/jwt-cpp/traits/danielaparker-jsoncons/traits.h @@ -131,30 +131,28 @@ namespace jwt { static jwt::json::type get_type(const json& val) { using jwt::json::type; - if (val.type() == jsoncons::json_type::bool_value) return type::boolean; - if (val.type() == jsoncons::json_type::int64_value) return type::integer; - if (val.type() == jsoncons::json_type::uint64_value) return type::integer; - if (val.type() == jsoncons::json_type::half_value) return type::number; - if (val.type() == jsoncons::json_type::double_value) return type::number; - if (val.type() == jsoncons::json_type::string_value) return type::string; - if (val.type() == jsoncons::json_type::array_value) return type::array; - if (val.type() == jsoncons::json_type::object_value) return type::object; + if (val.is_bool()) return type::boolean; + if (val.is_int64() || val.is_uint64()) return type::integer; + if (val.is_number()) return type::number; + if (val.is_string()) return type::string; + if (val.is_array()) return type::array; + if (val.is_object()) return type::object; throw std::logic_error("invalid type"); } static object_type as_object(const json& val) { - if (val.type() != jsoncons::json_type::object_value) throw std::bad_cast(); + if (!val.is_object()) throw std::bad_cast(); return object_type(val); } static array_type as_array(const json& val) { - if (val.type() != jsoncons::json_type::array_value) throw std::bad_cast(); + if (!val.is_array()) throw std::bad_cast(); return array_type(val); } static string_type as_string(const json& val) { - if (val.type() != jsoncons::json_type::string_value) throw std::bad_cast(); + if (!val.is_string()) throw std::bad_cast(); return val.as_string(); } @@ -169,7 +167,7 @@ namespace jwt { } static boolean_type as_boolean(const json& val) { - if (val.type() != jsoncons::json_type::bool_value) throw std::bad_cast(); + if (!val.is_bool()) throw std::bad_cast(); return val.as_bool(); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a9bd95584..d87bb7f24 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -193,6 +193,9 @@ if(JWT_ENABLE_COVERAGE) include("code-coverage") setup_coverage(jwt-cpp-test) set(COVERAGE_EXCLUDES "/usr/**" "*test*" "*build*" "**/picojson.h") + if(DEFINED ENV{RUNNER_TEMP}) + list(APPEND COVERAGE_EXCLUDES "$ENV{RUNNER_TEMP}/**") + endif() setup_target_for_coverage_lcov(NAME coverage EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-test LCOV_ARGS "--ignore-errors" "mismatch,mismatch,inconsistent") endif() diff --git a/tests/OpenSSLErrorTest.cpp b/tests/OpenSSLErrorTest.cpp index 52c7cac91..87941bc49 100644 --- a/tests/OpenSSLErrorTest.cpp +++ b/tests/OpenSSLErrorTest.cpp @@ -6,6 +6,11 @@ #include #include +// OpenSSL 4.1 bypasses the BIO_ctrl and X509_get_pubkey symbols interposed by these tests. +#if !defined(LIBWOLFSSL_VERSION_HEX) && OPENSSL_VERSION_NUMBER < 0x40100000L +#define JWT_TEST_BIO_CTRL_INTERPOSITION +#define JWT_TEST_X509_GET_PUBKEY_INTERPOSITION +#endif // TODO: Figure out why the tests fail on older openssl versions #ifndef JWT_OPENSSL_1_0_0 // It fails on < 1.1 but no idea why. // LibreSSL has different return codes but was already outside of the effective scope @@ -742,9 +747,11 @@ void run_multitest(const std::vector& mapping, Func fn) { TEST(OpenSSLErrorTest, ExtractPubkeyFromCert) { std::vector mapping{{&fail_BIO_new, 1, jwt::error::rsa_error::create_mem_bio_failed}, {&fail_PEM_read_bio_X509, 1, jwt::error::rsa_error::cert_load_failed}, +#ifdef JWT_TEST_X509_GET_PUBKEY_INTERPOSITION {&fail_X509_get_pubkey, 1, jwt::error::rsa_error::get_key_failed}, +#endif {&fail_PEM_write_bio_PUBKEY, 1, jwt::error::rsa_error::write_key_failed}, -#ifndef LIBWOLFSSL_VERSION_HEX /* wolfSSL does not use BIO_ctrl in BIO_get_mem_data */ +#ifdef JWT_TEST_BIO_CTRL_INTERPOSITION {&fail_BIO_ctrl, 1, jwt::error::rsa_error::convert_to_pem_failed} #endif }; @@ -760,9 +767,11 @@ TEST(OpenSSLErrorTest, ExtractPubkeyFromCert) { TEST(OpenSSLErrorTest, ExtractPubkeyFromCertErrorCode) { std::vector mapping{{&fail_BIO_new, 1, jwt::error::rsa_error::create_mem_bio_failed}, {&fail_PEM_read_bio_X509, 1, jwt::error::rsa_error::cert_load_failed}, +#ifdef JWT_TEST_X509_GET_PUBKEY_INTERPOSITION {&fail_X509_get_pubkey, 1, jwt::error::rsa_error::get_key_failed}, +#endif {&fail_PEM_write_bio_PUBKEY, 1, jwt::error::rsa_error::write_key_failed}, -#ifndef LIBWOLFSSL_VERSION_HEX /* wolfSSL does not use BIO_ctrl in BIO_get_mem_data */ +#ifdef JWT_TEST_BIO_CTRL_INTERPOSITION {&fail_BIO_ctrl, 1, jwt::error::rsa_error::convert_to_pem_failed} #endif }; @@ -928,14 +937,19 @@ TEST(OpenSSLErrorTest, ConvertCertBase64DerToPem) { }); } +// wolfSSL 5.9 parses the EdDSA certificate, so this injected failure reaches PEM writing. TEST(OpenSSLErrorTest, ConvertEcdsaCertBase64DerToPem) { - std::vector mapping{{&fail_BIO_new, 1, jwt::error::rsa_error::create_mem_bio_failed}, -#ifndef LIBWOLFSSL_VERSION_HEX - {&fail_PEM_write_bio_cert, 1, jwt::error::rsa_error::write_cert_failed}, - {&fail_BIO_ctrl, 1, jwt::error::rsa_error::convert_to_pem_failed} + std::vector mapping { + {&fail_BIO_new, 1, jwt::error::rsa_error::create_mem_bio_failed}, +#if defined(LIBWOLFSSL_VERSION_HEX) && LIBWOLFSSL_VERSION_HEX < 0x05009000 + {&fail_PEM_write_bio_cert, 1, jwt::error::rsa_error::create_mem_bio_failed} #else - {&fail_PEM_write_bio_cert, 1, jwt::error::rsa_error::create_mem_bio_failed}, - {&fail_BIO_ctrl, 1, jwt::error::rsa_error::create_mem_bio_failed} + {&fail_PEM_write_bio_cert, 1, jwt::error::rsa_error::write_cert_failed}, +#ifdef JWT_TEST_BIO_CTRL_INTERPOSITION + { + &fail_BIO_ctrl, 1, jwt::error::rsa_error::convert_to_pem_failed + } +#endif #endif }; @@ -950,7 +964,7 @@ TEST(OpenSSLErrorTest, ConvertEcdsaCertBase64DerToPem) { TEST(OpenSSLErrorTest, ConvertCertBase64DerToPemErrorCode) { std::vector mapping{{&fail_BIO_new, 1, jwt::error::rsa_error::create_mem_bio_failed}, {&fail_PEM_write_bio_cert, 1, jwt::error::rsa_error::write_cert_failed}, -#ifndef LIBWOLFSSL_VERSION_HEX /* wolfSSL does not use BIO_ctrl in BIO_get_mem_data */ +#ifdef JWT_TEST_BIO_CTRL_INTERPOSITION {&fail_BIO_ctrl, 1, jwt::error::rsa_error::convert_to_pem_failed} #endif }; @@ -1214,9 +1228,11 @@ TEST(OpenSSLErrorTest, ECDSACertificate) { // extract_pubkey_from_cert {&fail_BIO_new, 2, jwt::error::ecdsa_error::create_mem_bio_failed}, {&fail_PEM_read_bio_X509, 1, jwt::error::ecdsa_error::cert_load_failed}, +#ifdef JWT_TEST_X509_GET_PUBKEY_INTERPOSITION {&fail_X509_get_pubkey, 1, jwt::error::ecdsa_error::get_key_failed}, +#endif {&fail_PEM_write_bio_PUBKEY, 1, jwt::error::ecdsa_error::write_key_failed}, -#ifndef LIBWOLFSSL_VERSION_HEX /* wolfSSL does not use BIO_ctrl in BIO_get_mem_data */ +#ifdef JWT_TEST_BIO_CTRL_INTERPOSITION { &fail_BIO_ctrl, 1, jwt::error::ecdsa_error::convert_to_pem_failed } @@ -1358,10 +1374,17 @@ TEST(OpenSSLErrorTest, EdDSACertificate) { // extract_pubkey_from_cert {&fail_BIO_new, 2, jwt::error::rsa_error::create_mem_bio_failed}, {&fail_PEM_read_bio_X509, 1, jwt::error::rsa_error::cert_load_failed}, +#ifdef JWT_TEST_X509_GET_PUBKEY_INTERPOSITION {&fail_X509_get_pubkey, 1, jwt::error::rsa_error::get_key_failed}, - {&fail_PEM_write_bio_PUBKEY, 1, jwt::error::rsa_error::write_key_failed}, { - &fail_BIO_ctrl, 1, jwt::error::rsa_error::convert_to_pem_failed +#endif +#ifdef JWT_TEST_BIO_CTRL_INTERPOSITION + {&fail_PEM_write_bio_PUBKEY, 1, jwt::error::rsa_error::write_key_failed}, + {&fail_BIO_ctrl, 1, jwt::error::rsa_error::convert_to_pem_failed} +#else + { + &fail_PEM_write_bio_PUBKEY, 1, jwt::error::rsa_error::write_key_failed } +#endif }; run_multitest(mapping, [](std::error_code& ec) {