Skip to content

Instantly share code, notes, and snippets.

@anestos
Last active March 13, 2023 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anestos/d743e2444eaae33cc4bc0e6cbf0ab028 to your computer and use it in GitHub Desktop.
Save anestos/d743e2444eaae33cc4bc0e6cbf0ab028 to your computer and use it in GitHub Desktop.
Expose your local Curity installation on the internet
#!/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
EOF
fi
ngrok start -config ${CONFIG_FILE} curity &
NGROK_PID=$!
sleep 2
echo "Started Ngrok with PID $NGROK_PID"
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"
idsh --noninteractive << EOF
configure
set environments environment base-url ${BASE_URL}
commit
exit no-confirm
exit
EOF
fi
services=$(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]}')
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
@iggbom
Copy link

iggbom commented Feb 26, 2022

Looks like the link to that ngrok setup is now gated. Here's the public doc describing authtoken installation.

@mtrojanowski
Copy link

Just a note that there is also a separate script that exposes an instance of the Curity Identity Server started in a docker container: https://gist.github.com/mtrojanowski/fffba0c2fbca7229b43c1c448907bae8

@patriklindstrom
Copy link

To get it to work with latest ngrok version since there are breaking changes:

  • Add - before before config in ngrok start --config ${CONFIG_FILE} curity & in row 18
  • Add version and region in the config file

So in my script row 7 -- 18 are:

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 &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment