mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 13:11:41 +00:00
Merge pull request #3697 from DerVerruckteFuchs/1984-hosting-cookie-fix
1984 hosting cookie fix
This commit is contained in:
commit
35e22703af
@ -46,7 +46,7 @@ dns_1984hosting_add() {
|
|||||||
|
|
||||||
postdata="entry=new"
|
postdata="entry=new"
|
||||||
postdata="$postdata&type=TXT"
|
postdata="$postdata&type=TXT"
|
||||||
postdata="$postdata&ttl=3600"
|
postdata="$postdata&ttl=900"
|
||||||
postdata="$postdata&zone=$_domain"
|
postdata="$postdata&zone=$_domain"
|
||||||
postdata="$postdata&host=$_sub_domain"
|
postdata="$postdata&host=$_sub_domain"
|
||||||
postdata="$postdata&rdata=%22$value%22"
|
postdata="$postdata&rdata=%22$value%22"
|
||||||
@ -93,20 +93,15 @@ dns_1984hosting_rm() {
|
|||||||
fi
|
fi
|
||||||
_debug _sub_domain "$_sub_domain"
|
_debug _sub_domain "$_sub_domain"
|
||||||
_debug _domain "$_domain"
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
_debug "Delete $fulldomain TXT record"
|
_debug "Delete $fulldomain TXT record"
|
||||||
url="https://management.1984hosting.com/domains"
|
|
||||||
|
|
||||||
_htmlget "$url" "$_domain"
|
url="https://management.1984hosting.com/domains"
|
||||||
_debug2 _response "$_response"
|
if ! _get_zone_id "$url" "$_domain"; then
|
||||||
zone_id="$(echo "$_response" | _egrep_o 'zone\/[0-9]+')"
|
_err "invalid zone" "$_domain"
|
||||||
_debug2 zone_id "$zone_id"
|
|
||||||
if [ -z "$zone_id" ]; then
|
|
||||||
_err "Error getting zone_id for $1"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_htmlget "$url/$zone_id" "$_sub_domain"
|
_htmlget "$url/$_zone_id" "$txtvalue"
|
||||||
_debug2 _response "$_response"
|
_debug2 _response "$_response"
|
||||||
entry_id="$(echo "$_response" | _egrep_o 'entry_[0-9]+' | sed 's/entry_//')"
|
entry_id="$(echo "$_response" | _egrep_o 'entry_[0-9]+' | sed 's/entry_//')"
|
||||||
_debug2 entry_id "$entry_id"
|
_debug2 entry_id "$entry_id"
|
||||||
@ -135,7 +130,7 @@ dns_1984hosting_rm() {
|
|||||||
_1984hosting_login() {
|
_1984hosting_login() {
|
||||||
if ! _check_credentials; then return 1; fi
|
if ! _check_credentials; then return 1; fi
|
||||||
|
|
||||||
if _check_cookie; then
|
if _check_cookies; then
|
||||||
_debug "Already logged in"
|
_debug "Already logged in"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -150,9 +145,12 @@ _1984hosting_login() {
|
|||||||
_debug2 response "$response"
|
_debug2 response "$response"
|
||||||
|
|
||||||
if _contains "$response" '"loggedin": true'; then
|
if _contains "$response" '"loggedin": true'; then
|
||||||
One984HOSTING_COOKIE="$(grep -i '^set-cookie:' "$HTTP_HEADER" | _tail_n 1 | _egrep_o 'sessionid=[^;]*;' | tr -d ';')"
|
One984HOSTING_SESSIONID_COOKIE="$(grep -i '^set-cookie:' "$HTTP_HEADER" | _egrep_o 'sessionid=[^;]*;' | tr -d ';')"
|
||||||
export One984HOSTING_COOKIE
|
One984HOSTING_CSRFTOKEN_COOKIE="$(grep -i '^set-cookie:' "$HTTP_HEADER" | _egrep_o 'csrftoken=[^;]*;' | tr -d ';')"
|
||||||
_saveaccountconf_mutable One984HOSTING_COOKIE "$One984HOSTING_COOKIE"
|
export One984HOSTING_SESSIONID_COOKIE
|
||||||
|
export One984HOSTING_CSRFTOKEN_COOKIE
|
||||||
|
_saveaccountconf_mutable One984HOSTING_SESSIONID_COOKIE "$One984HOSTING_SESSIONID_COOKIE"
|
||||||
|
_saveaccountconf_mutable One984HOSTING_CSRFTOKEN_COOKIE "$One984HOSTING_CSRFTOKEN_COOKIE"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
@ -169,21 +167,24 @@ _check_credentials() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
_check_cookie() {
|
_check_cookies() {
|
||||||
One984HOSTING_COOKIE="${One984HOSTING_COOKIE:-$(_readaccountconf_mutable One984HOSTING_COOKIE)}"
|
One984HOSTING_SESSIONID_COOKIE="${One984HOSTING_SESSIONID_COOKIE:-$(_readaccountconf_mutable One984HOSTING_SESSIONID_COOKIE)}"
|
||||||
if [ -z "$One984HOSTING_COOKIE" ]; then
|
One984HOSTING_CSRFTOKEN_COOKIE="${One984HOSTING_CSRFTOKEN_COOKIE:-$(_readaccountconf_mutable One984HOSTING_CSRFTOKEN_COOKIE)}"
|
||||||
_debug "No cached cookie found"
|
if [ -z "$One984HOSTING_SESSIONID_COOKIE" ] || [ -z "$One984HOSTING_CSRFTOKEN_COOKIE" ]; then
|
||||||
|
_debug "No cached cookie(s) found"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_authget "https://management.1984hosting.com/accounts/loginstatus/"
|
_authget "https://management.1984hosting.com/accounts/loginstatus/"
|
||||||
if _contains "$response" '"ok": true'; then
|
if _contains "$response" '"ok": true'; then
|
||||||
_debug "Cached cookie still valid"
|
_debug "Cached cookies still valid"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
_debug "Cached cookie no longer valid"
|
_debug "Cached cookies no longer valid"
|
||||||
One984HOSTING_COOKIE=""
|
One984HOSTING_SESSIONID_COOKIE=""
|
||||||
_saveaccountconf_mutable One984HOSTING_COOKIE "$One984HOSTING_COOKIE"
|
One984HOSTING_CSRFTOKEN_COOKIE=""
|
||||||
|
_saveaccountconf_mutable One984HOSTING_SESSIONID_COOKIE "$One984HOSTING_SESSIONID_COOKIE"
|
||||||
|
_saveaccountconf_mutable One984HOSTING_CSRFTOKEN_COOKIE "$One984HOSTING_CSRFTOKEN_COOKIE"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,9 +216,25 @@ _get_root() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#usage: _get_zone_id url domain.com
|
||||||
|
#returns zone id for domain.com
|
||||||
|
_get_zone_id() {
|
||||||
|
url=$1
|
||||||
|
domain=$2
|
||||||
|
_htmlget "$url" "$domain"
|
||||||
|
_debug2 _response "$_response"
|
||||||
|
_zone_id="$(echo "$_response" | _egrep_o 'zone\/[0-9]+' | _head_n 1)"
|
||||||
|
_debug2 _zone_id "$_zone_id"
|
||||||
|
if [ -z "$_zone_id" ]; then
|
||||||
|
_err "Error getting _zone_id for $2"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# add extra headers to request
|
# add extra headers to request
|
||||||
_authget() {
|
_authget() {
|
||||||
export _H1="Cookie: $One984HOSTING_COOKIE"
|
export _H1="Cookie: $One984HOSTING_CSRFTOKEN_COOKIE;$One984HOSTING_SESSIONID_COOKIE"
|
||||||
_response=$(_get "$1" | _normalizeJson)
|
_response=$(_get "$1" | _normalizeJson)
|
||||||
_debug2 _response "$_response"
|
_debug2 _response "$_response"
|
||||||
}
|
}
|
||||||
@ -225,12 +242,20 @@ _authget() {
|
|||||||
# truncate huge HTML response
|
# truncate huge HTML response
|
||||||
# echo: Argument list too long
|
# echo: Argument list too long
|
||||||
_htmlget() {
|
_htmlget() {
|
||||||
export _H1="Cookie: $One984HOSTING_COOKIE"
|
export _H1="Cookie: $One984HOSTING_CSRFTOKEN_COOKIE;$One984HOSTING_SESSIONID_COOKIE"
|
||||||
_response=$(_get "$1" | grep "$2" | _head_n 1)
|
_response=$(_get "$1" | grep "$2")
|
||||||
|
if _contains "$_response" "@$2"; then
|
||||||
|
_response=$(echo "$_response" | grep -v "[@]" | _head_n 1)
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# add extra headers to request
|
# add extra headers to request
|
||||||
_authpost() {
|
_authpost() {
|
||||||
export _H1="Cookie: $One984HOSTING_COOKIE"
|
url="https://management.1984hosting.com/domains"
|
||||||
|
_get_zone_id "$url" "$_domain"
|
||||||
|
csrf_header="$(echo "$One984HOSTING_CSRFTOKEN_COOKIE" | _egrep_o "=[^=][0-9a-zA-Z]*" | tr -d "=")"
|
||||||
|
export _H1="Cookie: $One984HOSTING_CSRFTOKEN_COOKIE;$One984HOSTING_SESSIONID_COOKIE"
|
||||||
|
export _H2="Referer: https://management.1984hosting.com/domains/$_zone_id"
|
||||||
|
export _H3="X-CSRFToken: $csrf_header"
|
||||||
_response=$(_post "$1" "$2")
|
_response=$(_post "$1" "$2")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user