diff --git a/auth/Dockerfile b/auth/Dockerfile index 1335cd1..af4bd13 100644 --- a/auth/Dockerfile +++ b/auth/Dockerfile @@ -21,4 +21,3 @@ RUN wget -q -O - https://github.com/msoap/shell2http/releases/download/v1.16.0/s RUN wget -q -O - https://github.com/mike-engel/jwt-cli/releases/download/5.0.3/jwt-linux.tar.gz | tar xvz -C /usr/local/bin jwt ADD --chmod=a+x issue_jwt.sh issue_jwt.sh -CMD ["shell2http", "--cgi", "--show-errors", "--form", "--export-all-vars", "POST:/", "./issue_jwt.sh"] \ No newline at end of file diff --git a/auth/issue_jwt.sh b/auth/issue_jwt.sh index ce3b642..cf5f221 100755 --- a/auth/issue_jwt.sh +++ b/auth/issue_jwt.sh @@ -1,6 +1,11 @@ #! /bin/bash set -euo pipefail +# Logging function (to stderr) +log(){ + >&2 echo "--- $(date --rfc-3339) - $*" +} + # Define a function to create a JSON object from all available variables matching 'prefix' jsonify_prefixed_variables() { # Read the prefix to use @@ -86,7 +91,10 @@ fi env_json=$(jsonify_prefixed_variables "JWT_CLAIM_") # Merged json (Note the order! Later entries overwrites earlier ones!) -merged_json=$(echo "$form_data_json $env_json" | jq -s add | jq 'to_entries | reduce .[] as $item ({}; .[$item.key] = $item.value)') +merged_json=$(echo "$form_data_json $env_json" | jq -s add | jq -c 'to_entries | reduce .[] as $item ({}; .[$item.key] = $item.value)') + +# Log the final token payload (claims) +log "$merged_json" # Create token and return it token=$( @@ -97,4 +105,7 @@ token=$( "$merged_json" ) +# And log the token +log "$token" + echo "$token" \ No newline at end of file diff --git a/docker-compose.base.yml b/docker-compose.base.yml index f792795..04325a9 100644 --- a/docker-compose.base.yml +++ b/docker-compose.base.yml @@ -4,7 +4,7 @@ services: # Reverse proxy traefik: - image: "traefik:v2.10.1" + image: "traefik:v2.10.5" restart: unless-stopped # Static configuration of Traefik @@ -42,7 +42,7 @@ services: # MQTT broker emqx: - image: emqx/emqx:5.1.0 + image: emqx/emqx:5.3.0 restart: unless-stopped environment: - EMQX_NAME=pontos-hub @@ -104,7 +104,7 @@ services: # REST api api: - image: postgrest/postgrest:v11.1.0 + image: postgrest/postgrest:v11.2.2 restart: unless-stopped environment: - PGRST_DB_URI=postgres://authenticator:${PONTOS_DB_PASSWORD}@db:5432/pontos @@ -133,7 +133,7 @@ services: # Swagger api docs swagger: - image: swaggerapi/swagger-ui:v5.1.0 + image: swaggerapi/swagger-ui:v5.9.1 restart: unless-stopped environment: - API_URL=/api