Browse Source

update to new sso login

pull/1516/head
Peter Postmann 7 years ago
parent
commit
bcda632dff
  1. 35
      dnsapi/dns_hosteurope.sh

35
dnsapi/dns_hosteurope.sh

@ -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 [ $? -ne 0 ]; then
if ! headers=$(cat "$HTTP_HEADER"); 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 [ $? -ne 0 ]; then
if ! cookies=$(echo "$headers" | sed -n -e 's/^Set-Cookie: //p'); then
_err "error authidp cookie not found" _err "error authidp cookie not found"
_debug2 headers $headers
_debug2 cookies $cookies
_debug2 headers "$headers"
_debug2 cookies "$cookies"
return 1 return 1
fi fi
authidp=$(echo "$cookies" | grep "auth_idp=")
if [ $? -ne 0 ]; then
if ! authidp=$(echo "$cookies" | grep "auth_idp="); 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 [ $? -ne 0 ]; then
if ! HOSTEUROPE_Cookie=$(echo "$cookies" | awk '{print $1}' | tr -d '\n'); 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 [ $? -ne 0 ]; then
if ! expires=$(echo "$authidp" | sed -n -e 's/.*Expires=//p' | sed -n -e 's/;.*//p'); 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="$?"

Loading…
Cancel
Save