diff --git a/.reaction/project-hooks/post-project-start b/.reaction/project-hooks/post-project-start index 7ed065e..9a48ad0 100755 --- a/.reaction/project-hooks/post-project-start +++ b/.reaction/project-hooks/post-project-start @@ -19,13 +19,8 @@ # - It is good practice to keep this script lightweight and invoke setup # scripts in your project. -#__current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +__current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" __root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" __root_name=$(basename "${__root_dir}") echo "${__root_name} post-project-start script invoked." 2>&1 - -# TODO: Consider moving the oauth client creation to post-system-start in the -# projects they represent. -echo "Creating development OAuth clients for ${__root_name}" -"${__root_dir}/bin/create-clients.sh" diff --git a/bin/create-clients.sh b/bin/create-clients.sh deleted file mode 100755 index 7d702c3..0000000 --- a/bin/create-clients.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# Creates basic OAuth2 clients. -# -# WARNING!!! WARNING!!! WARNING!!! -# For DEVELOPMENT USE ONLY! -# -# * You should not provide secrets using command line flags. -# The secret might leak to bash history and similar systems. -# * The passwords used here are VERY INSECURE. -# * Restrict grant-types to a FEW AS POSSIBLE. -# * Restrict scope as much as possible. - -__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -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}" \ - --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}" \ - --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 diff --git a/bin/wait-for.sh b/bin/wait-for.sh deleted file mode 100755 index ddfc39e..0000000 --- a/bin/wait-for.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh - -TIMEOUT=15 -QUIET=0 - -echoerr() { - if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi -} - -usage() { - exitcode="$1" - cat << USAGE >&2 -Usage: - $cmdname host:port [-t timeout] [-- command args] - -q | --quiet Do not output any status messages - -t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit "$exitcode" -} - -wait_for() { - for i in `seq $TIMEOUT` ; do - nc -z "$HOST" "$PORT" > /dev/null 2>&1 - - result=$? - if [ $result -eq 0 ] ; then - if [ $# -gt 0 ] ; then - exec "$@" - fi - exit 0 - fi - sleep 1 - done - echo "Operation timed out" >&2 - exit 1 -} - -while [ $# -gt 0 ] -do - case "$1" in - *:* ) - HOST=$(printf "%s\n" "$1"| cut -d : -f 1) - PORT=$(printf "%s\n" "$1"| cut -d : -f 2) - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -t) - TIMEOUT="$2" - if [ "$TIMEOUT" = "" ]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - break - ;; - --help) - usage 0 - ;; - *) - echoerr "Unknown argument: $1" - usage 1 - ;; - esac -done - -if [ "$HOST" = "" -o "$PORT" = "" ]; then - echoerr "Error: you need to provide a host and port to test." - usage 2 -fi - -wait_for "$@"