Skip to content

Commit

Permalink
update tools for uaa/ldap user authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ogrand committed May 14, 2018
1 parent 46f4c92 commit 79ffce5
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 112 deletions.
40 changes: 14 additions & 26 deletions scripts/log-cf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export STD='\033[0m'
export BOLD='\033[1m'
export REVERSE='\033[7m'

flagError=0

getCredhub() {
#--- Test if parameter exist with non empty value, else get it from credhub
if [ "${!1}" = "" ] ; then
Expand All @@ -29,29 +27,20 @@ getCredhub() {
}

#--- Log to credhub
status=`env | grep CREDHUB_SECRET`
if [ "${status}" = "" ] ; then
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CLIENT="director_to_credhub"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flag=0
while [ ${flag} = 0 ] ; do
clear
printf "%bEnter credhub password :%b " "${REVERSE}${YELLOW}" "${STD}" ; read -s CREDHUB_SECRET
if [ "${CREDHUB_SECRET}" != "" ] ; then
flag=1
fi
done
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flagError=0

export CREDHUB_SECRET
credhub api > /dev/null 2>&1
credhub login > /dev/null 2>&1
if [ $? = 1 ] ; then
printf "\n%bERROR : Bad credhub password.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
flag=`credhub f 2>&1 | grep "not currently authenticated"`
if [ "${flag}" != "" ] ; then
printf "%bEnter CF LDAP user and password :%b\n" "${REVERSE}${YELLOW}" "${STD}"
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand All @@ -60,8 +49,7 @@ fi
#--- Log to CF
if [ "${flagError}" = "0" ] ; then
flag=0
while [ ${flag} = 0 ]
do
while [ ${flag} = 0 ] ; do
clear
printf "%bEnter CF User :%b " "${REVERSE}${YELLOW}" "${STD}" ; read CF_USER
if [ "${CF_USER}" != "" ] ; then
Expand Down
28 changes: 10 additions & 18 deletions scripts/log-credhub
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,19 @@ export REVERSE='\033[7m'

#--- Log to credhub
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CLIENT="director_to_credhub"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"

if [ ! -s "${CREDHUB_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${CREDHUB_CA_CERT}\" unknown.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
else
flag=0
while [ ${flag} = 0 ] ; do
clear
printf "%bEnter credhub password :%b " "${REVERSE}${YELLOW}" "${STD}" ; read -s CREDHUB_SECRET
if [ "${CREDHUB_SECRET}" != "" ] ; then
flag=1
flag=`credhub f 2>&1 | grep "not currently authenticated"`
if [ "${flag}" != "" ] ; then
printf "%bEnter CF LDAP user and password :%b\n" "${REVERSE}${YELLOW}" "${STD}"
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
else
printf "\n\n"
fi
done

export CREDHUB_SECRET
credhub api > /dev/null 2>&1
credhub login > /dev/null 2>&1
if [ $? = 1 ] ; then
printf "\n%bERROR : Bad credhub password.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
else
printf "\n\n"
fi
fi
35 changes: 13 additions & 22 deletions scripts/log-fly
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,20 @@ getCredhub() {
}

#--- Log to credhub
status=`env | grep CREDHUB_SECRET`
if [ "${status}" = "" ] ; then
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CLIENT="director_to_credhub"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flag=0
while [ ${flag} = 0 ] ; do
clear
printf "%bEnter credhub password :%b " "${REVERSE}${YELLOW}" "${STD}" ; read -s CREDHUB_SECRET
if [ "${CREDHUB_SECRET}" != "" ] ; then
flag=1
fi
done
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flagError=0

export CREDHUB_SECRET
credhub api > /dev/null 2>&1
credhub login > /dev/null 2>&1
if [ $? = 1 ] ; then
printf "\n\n%bERROR : Bad credhub password.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
flag=`credhub f 2>&1 | grep "not currently authenticated"`
if [ "${flag}" != "" ] ; then
printf "%bEnter CF LDAP user and password :%b\n" "${REVERSE}${YELLOW}" "${STD}"
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand Down
37 changes: 13 additions & 24 deletions scripts/log-mc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export STD='\033[0m'
export BOLD='\033[1m'
export REVERSE='\033[7m'

flagError=0

getCredhub() {
#--- Test if parameter exist with non empty value, else get it from credhub
if [ "${!1}" = "" ] ; then
Expand All @@ -29,29 +27,20 @@ getCredhub() {
}

#--- Log to credhub
status=`env | grep CREDHUB_SECRET`
if [ "${status}" = "" ] ; then
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CLIENT="director_to_credhub"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flag=0
while [ ${flag} = 0 ] ; do
clear
printf "%bEnter credhub password :%b " "${REVERSE}${YELLOW}" "${STD}" ; read -s CREDHUB_SECRET
if [ "${CREDHUB_SECRET}" != "" ] ; then
flag=1
fi
done
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flagError=0

export CREDHUB_SECRET
credhub api > /dev/null 2>&1
credhub login > /dev/null 2>&1
if [ $? = 1 ] ; then
printf "\n%bERROR : Bad credhub password.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
flag=`credhub f 2>&1 | grep "not currently authenticated"`
if [ "${flag}" != "" ] ; then
printf "%bEnter CF LDAP user and password :%b\n" "${REVERSE}${YELLOW}" "${STD}"
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand Down
35 changes: 13 additions & 22 deletions scripts/log-openstack
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,20 @@ getCredhub() {
}

#--- Log to credhub
status=`env | grep CREDHUB_SECRET`
if [ "${status}" = "" ] ; then
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CLIENT="director_to_credhub"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flag=0
while [ ${flag} = 0 ] ; do
clear
printf "%bEnter credhub password :%b " "${REVERSE}${YELLOW}" "${STD}" ; read -s CREDHUB_SECRET
if [ "${CREDHUB_SECRET}" != "" ] ; then
flag=1
fi
done
export CREDHUB_SERVER="https://credhub.internal.paas:8844"
export CREDHUB_CA_CERT="${BOSH_CA_CERT}"
flagError=0

export CREDHUB_SECRET
credhub api > /dev/null 2>&1
credhub login > /dev/null 2>&1
if [ $? = 1 ] ; then
printf "\n%bERROR : Bad credhub password.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
if [ ! -s "${BOSH_CA_CERT}" ] ; then
printf "\n%bERROR : CA cert file \"${BOSH_CA_CERT}\" unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
else
flag=`credhub f 2>&1 | grep "not currently authenticated"`
if [ "${flag}" != "" ] ; then
printf "%bEnter CF LDAP user and password :%b\n" "${REVERSE}${YELLOW}" "${STD}"
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand Down

0 comments on commit 79ffce5

Please sign in to comment.