Skip to content

Commit

Permalink
Bumping versions and adding some log statements to the issue_jwt.sh s…
Browse files Browse the repository at this point in the history
…cript
  • Loading branch information
freol35241 committed Nov 1, 2023
1 parent 90787ae commit 9020e17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
13 changes: 12 additions & 1 deletion auth/issue_jwt.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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=$(
Expand All @@ -97,4 +105,7 @@ token=$(
"$merged_json"
)

# And log the token
log "$token"

echo "$token"
8 changes: 4 additions & 4 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9020e17

Please sign in to comment.