update to new sso login
This commit is contained in:
parent
9abb7a7d29
commit
bcda632dff
@ -76,7 +76,7 @@ dns_hosteurope_rm() {
|
|||||||
_hostid="$(echo "$response" | grep -a -A 50 "$txtvalue" | grep -m 1 "hostid" | grep -o 'value="[^"]*' | grep -o '[^"]*$')"
|
_hostid="$(echo "$response" | grep -a -A 50 "$txtvalue" | grep -m 1 "hostid" | grep -o 'value="[^"]*' | grep -o '[^"]*$')"
|
||||||
_debug _hostid "$_hostid"
|
_debug _hostid "$_hostid"
|
||||||
|
|
||||||
if [ -z "$_hostid" ] ; then
|
if [ -z "$_hostid" ]; then
|
||||||
_err "record not found"
|
_err "record not found"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -102,7 +102,7 @@ _get_root() {
|
|||||||
_debug2 domains "$_domains"
|
_debug2 domains "$_domains"
|
||||||
|
|
||||||
for _d in $_domains; do
|
for _d in $_domains; do
|
||||||
if echo "$domain" | grep "$_d$" > /dev/null; then
|
if echo "$domain" | grep "$_d$" >/dev/null; then
|
||||||
_domain="$_d"
|
_domain="$_d"
|
||||||
_sub_domain="$(echo "$domain" | sed "s/$_d$//g" | sed "s/\\.$//g")"
|
_sub_domain="$(echo "$domain" | sed "s/$_d$//g" | sed "s/\\.$//g")"
|
||||||
return 0
|
return 0
|
||||||
@ -119,7 +119,7 @@ _hosteurope_login() {
|
|||||||
_readaccountconf_mutable HOSTEUROPE_Cookie "$HOSTEUROPE_Cookie"
|
_readaccountconf_mutable HOSTEUROPE_Cookie "$HOSTEUROPE_Cookie"
|
||||||
_readaccountconf_mutable HOSTEUROPE_Expires "$HOSTEUROPE_Expires"
|
_readaccountconf_mutable HOSTEUROPE_Expires "$HOSTEUROPE_Expires"
|
||||||
|
|
||||||
if [ ! -z "$HOSTEUROPE_Cookie" ] && [ ! -z "$HOSTEUROPE_Expires" ] && [ $HOSTEUROPE_Expires -gt $(date "+%s") ]; then
|
if [ -n "$HOSTEUROPE_Cookie" ] && [ -n "$HOSTEUROPE_Expires" ] && [ "$HOSTEUROPE_Expires" -gt "$(date "+%s")" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -130,46 +130,43 @@ _hosteurope_login() {
|
|||||||
|
|
||||||
if [ "$response" != '{"success":true}' ]; then
|
if [ "$response" != '{"success":true}' ]; then
|
||||||
_err "error $response"
|
_err "error $response"
|
||||||
_debug2 response $response
|
_debug2 response "$response"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
headers=$(cat $HTTP_HEADER)
|
if ! headers=$(cat "$HTTP_HEADER"); then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "error headers not found"
|
_err "error headers not found"
|
||||||
_debug2 HTTP_HEADER $HTTP_HEADER
|
_debug2 HTTP_HEADER "$HTTP_HEADER"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cookies=$(echo "$headers" | sed -n -e 's/^Set-Cookie: //p')
|
if ! cookies=$(echo "$headers" | sed -n -e 's/^Set-Cookie: //p'); then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "error authidp cookie not found"
|
_err "error authidp cookie not found"
|
||||||
_debug2 headers $headers
|
_debug2 headers "$headers"
|
||||||
_debug2 cookies $cookies
|
_debug2 cookies "$cookies"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
authidp=$(echo "$cookies" | grep "auth_idp=")
|
if ! authidp=$(echo "$cookies" | grep "auth_idp="); then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "error authidp cookie not found"
|
_err "error authidp cookie not found"
|
||||||
_debug2 cookies $cookies
|
_debug2 cookies "$cookies"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOSTEUROPE_Cookie=$(echo "$cookies" | awk '{print $1}' | tr -d '\n')
|
if ! HOSTEUROPE_Cookie=$(echo "$cookies" | awk '{print $1}' | tr -d '\n'); then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "error parsing cookie"
|
_err "error parsing cookie"
|
||||||
_debug2 cookies $cookies
|
_debug2 cookies "$cookies"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOSTEUROPE_Expires=$(echo "$authidp" | sed -n -e 's/.*Expires=//p' | sed -n -e 's/;.*//p' | { read gmt ; date -d "$gmt" "+%s" ; })
|
if ! expires=$(echo "$authidp" | sed -n -e 's/.*Expires=//p' | sed -n -e 's/;.*//p'); then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "error parsing cookie expiration date"
|
_err "error parsing cookie expiration date"
|
||||||
_debug2 authidp $authidp
|
_debug2 authidp "$authidp"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
HOSTEUROPE_Expires=$(date -d "$expires" "+%s")
|
||||||
|
|
||||||
_saveaccountconf_mutable HOSTEUROPE_Cookie "$HOSTEUROPE_Cookie"
|
_saveaccountconf_mutable HOSTEUROPE_Cookie "$HOSTEUROPE_Cookie"
|
||||||
_saveaccountconf_mutable HOSTEUROPE_Expires "$HOSTEUROPE_Expires"
|
_saveaccountconf_mutable HOSTEUROPE_Expires "$HOSTEUROPE_Expires"
|
||||||
|
|
||||||
@ -182,7 +179,7 @@ _hosteurope_get() {
|
|||||||
|
|
||||||
_hosteurope_login "$HOSTEUROPE_Username" "$HOSTEUROPE_Password"
|
_hosteurope_login "$HOSTEUROPE_Username" "$HOSTEUROPE_Password"
|
||||||
_H1="Cookie: $HOSTEUROPE_Cookie"
|
_H1="Cookie: $HOSTEUROPE_Cookie"
|
||||||
_debug2 Cookie $_H1
|
_debug2 Cookie "$_H1"
|
||||||
|
|
||||||
response="$(_get "${HOSTEUROPE_Api}${ep}")"
|
response="$(_get "${HOSTEUROPE_Api}${ep}")"
|
||||||
res="$?"
|
res="$?"
|
||||||
@ -193,17 +190,17 @@ _hosteurope_get() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$response" | grep "<title>KIS Login</title>" > /dev/null; then
|
if echo "$response" | grep "<title>KIS Login</title>" >/dev/null; then
|
||||||
_err "Invalid Credentials"
|
_err "Invalid Credentials"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$response" | grep "FEHLER" > /dev/null; then
|
if echo "$response" | grep "FEHLER" >/dev/null; then
|
||||||
_err "$(_hosteurope_result "$response" "FEHLER")"
|
_err "$(_hosteurope_result "$response" "FEHLER")"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$response" | grep "INFO" > /dev/null; then
|
if echo "$response" | grep "INFO" >/dev/null; then
|
||||||
_info "$(_hosteurope_result "$response" "INFO")"
|
_info "$(_hosteurope_result "$response" "INFO")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user