Skip to content

Commit

Permalink
Merge pull request #4 from reactioncommerce/fix-2-pete-create-clients
Browse files Browse the repository at this point in the history
fix: wait for hydra then create the dev client
  • Loading branch information
aldeed authored Sep 19, 2018
2 parents 8783325 + ee010f0 commit a5f43c4
Showing 1 changed file with 39 additions and 20 deletions.
59 changes: 39 additions & 20 deletions bin/create-clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,44 @@

__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

docker_image=oryd/hydra:v1.0.0-beta.9-alpine
network=auth.reaction.localhost
hydra_admin_port=4445
hydra_admin_url=http://hydra.${network}:${hydra_admin_port}

# Logs a warning and fails silently for now. Hydra doesn't support updating
# with this command.
docker run --rm -it \
docker_image="oryd/hydra:v1.0.0-beta.9-alpine"
network="auth.reaction.localhost"
hydra_host="hydra.${network}"
hydra_admin_port="4445"
hydra_admin_url="http://${hydra_host}:${hydra_admin_port}"
docker run --rm \
--interactive \
--volume "${__dir}/wait-for.sh:/usr/local/bin/wait-for.sh" \
--network "${network}" \
--volume "${__dir}/wait-for-it.sh:/usr/local/bin/wait-for-it.sh" \
-e "HYDRA_ADMIN_URL=${hydra_admin_url}" \
--env "HYDRA_HOST=${hydra_host}" \
--env "HYDRA_ADMIN_PORT=${hydra_admin_port}" \
--env "HYDRA_ADMIN_URL=${hydra_admin_url}" \
--env "HYDRA_CLIENT_SECRET" \
--network "${network}" \
"${docker_image}" \
clients create --skip-tls-verify \
--id reaction-next-starterkit \
--secret CHANGEME \
--grant-types authorization_code,refresh_token,client_credentials,implicit \
--token-endpoint-auth-method client_secret_post \
--response-types token,code,id_token \
--scope openid,offline \
--callbacks http://localhost:4000/callback \
|| echo "Failed to create OAuth2 client 'reaction-next-starterkit'"
--entrypoint sh \
"${docker_image}" <<'EOF'
/usr/local/bin/wait-for.sh "${HYDRA_HOST}:${HYDRA_ADMIN_PORT}"
hydra clients create --skip-tls-verify \
--id reaction-next-starterkit \
--secret "${HYDRA_CLIENT_SECRET-CHANGEME}" \
--grant-types authorization_code,refresh_token,client_credentials,implicit \
--token-endpoint-auth-method client_secret_post \
--response-types token,code,id_token \
--scope openid,offline \
--callbacks http://localhost:4000/callback 2>/tmp/clients-create-stderr
exit_code=$?
case ${exit_code} in
0)
echo SUCCESS: hydra client created
;;
*)
if grep 409 /tmp/clients-create-stderr >/dev/null; then
echo SUCCESS: hydra client already exists
else
echo ERROR: creating hydra client 1>&2
cat /tmp/clients-create-stderr 1>&2
exit ${exit_code}
fi
;;
esac
EOF

0 comments on commit a5f43c4

Please sign in to comment.