Last active
March 21, 2023 12:00
-
-
Save mtrojanowski/fffba0c2fbca7229b43c1c448907bae8 to your computer and use it in GitHub Desktop.
Updated ngrok config and command to work with ngrok v3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -m | |
mkdir -p $HOME/.ngrok2 | |
CONFIG_FILE="$HOME/.ngrok2/curity.yml" | |
if [[ ! -e "$CONFIG_FILE" ]]; then | |
cat <<EOF > ${CONFIG_FILE} | |
console_ui: false | |
tunnels: | |
curity: | |
proto: http | |
addr: 8443 | |
version: "2" | |
region: "eu" | |
EOF | |
fi | |
ngrok start --config ${CONFIG_FILE} curity & | |
NGROK_PID=$! | |
sleep 2 | |
echo "Started Ngrok with PID $NGROK_PID" | |
IDSVR_CONTAINER_ID=$(docker ps | grep curity.azurecr.io/curity/idsvr | awk '{split($0, column, " "); print column[1]}') | |
BASE_URL=$(curl -s http://localhost:4040/api/tunnels | jq -r '.tunnels[] | select(.proto == "https") | .public_url') | |
if [[ -n "$BASE_URL" ]]; then | |
echo "Setting base url to $BASE_URL" | |
docker exec -i $IDSVR_CONTAINER_ID idsh --noninteractive << EOF | |
configure | |
set environments environment base-url ${BASE_URL} | |
commit | |
exit no-confirm | |
exit | |
EOF | |
fi | |
services=$(docker exec -i $IDSVR_CONTAINER_ID idsh <<< "show configuration environments environment services service-role | display-level 1") | |
while IFS= read -r service | |
do | |
service=$(echo ${service} | sed 's/\;//g') | |
name=$(echo ${service} | awk '{split($0, column, " "); print column[2]}') | |
docker exec -i $IDSVR_CONTAINER_ID idsh --noninteractive << EOF | |
configure | |
set environments environment services service-role ${name} webfinger | |
set environments environment services service-role ${name} protocol http | |
commit | |
exit no-confirm | |
exit | |
EOF | |
done <<< "$services" | |
echo "Exposing local Curity instance at $BASE_URL" | |
echo "To begin using this, click here: https://oauth.tools#new-env=${BASE_URL}/&webfinger=true" | |
fg %1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that if you have more containers running the Curity Identity Server, you should update the script to modify only the container you want to expose. If you configured the container to map port 8443 to a different host port, you should also update the ngrok configuration.