Fixed auth for non-2FA

This commit is contained in:
Chris Gelatt 2017-09-21 10:11:17 -07:00
parent 9559f3514b
commit 3c04e13ec3

View File

@ -34,13 +34,21 @@ dns_he_add() {
_clearaccountconf HE_OTP_Secret _clearaccountconf HE_OTP_Secret
fi fi
if [ ! -z "$HE_OTP_Secret" ]; then
_sign_in _sign_in
fi
# Fills in the $_zone_id # Fills in the $_zone_id
_find_zone "$_full_domain" || return 1 _find_zone "$_full_domain" || return 1
_debug "Zone id \"$_zone_id\" will be used." _debug "Zone id \"$_zone_id\" will be used."
if [ ! -z "$HE_OTP_Secret" ]; then
body="account=" body="account="
else
body="email=${HE_Username}&pass=${HE_Password}"
body="$body&account="
fi
body="$body&menu=edit_zone" body="$body&menu=edit_zone"
body="$body&Type=TXT" body="$body&Type=TXT"
body="$body&hosted_dns_zoneid=$_zone_id" body="$body&hosted_dns_zoneid=$_zone_id"
@ -60,7 +68,9 @@ dns_he_add() {
fi fi
_debug2 response "$response" _debug2 response "$response"
if [ ! -z "$HE_OTP_Secret" ]; then
_sign_out _sign_out
fi
return "$exit_code" return "$exit_code"
} }
@ -73,14 +83,22 @@ dns_he_rm() {
_txt_value=$2 _txt_value=$2
_info "Cleaning up after DNS-01 Hurricane Electric hook" _info "Cleaning up after DNS-01 Hurricane Electric hook"
if [ ! -z "$HE_OTP_Secret" ]; then
_sign_in _sign_in
fi
# fills in the $_zone_id # fills in the $_zone_id
_find_zone "$_full_domain" || return 1 _find_zone "$_full_domain" || return 1
_debug "Zone id \"$_zone_id\" will be used." _debug "Zone id \"$_zone_id\" will be used."
# Find the record id to clean # Find the record id to clean
if [ ! -z "$HE_OTP_Secret" ]; then
body="hosted_dns_zoneid=$_zone_id" body="hosted_dns_zoneid=$_zone_id"
else
body="email=${HE_Username}&pass=${HE_Password}"
body="$body&hosted_dns_zoneid=$_zone_id"
fi
body="$body&menu=edit_zone" body="$body&menu=edit_zone"
body="$body&hosted_dns_editzone=" body="$body&hosted_dns_editzone="
domain_regex="$(echo "$_full_domain" | sed 's/\./\\./g')" # escape dots domain_regex="$(echo "$_full_domain" | sed 's/\./\\./g')" # escape dots
@ -95,6 +113,13 @@ dns_he_rm() {
# HE changes their website somehow). # HE changes their website somehow).
# Remove the record # Remove the record
if [ ! -z "$HE_OTP_Secret" ]; then
body="menu=edit_zone"
else
body="email=${HE_Username}&pass=${HE_Password}"
body="$body&menu=edit_zone"
fi
body="menu=edit_zone" body="menu=edit_zone"
body="$body&hosted_dns_zoneid=$_zone_id" body="$body&hosted_dns_zoneid=$_zone_id"
body="$body&hosted_dns_recordid=$_record_id" body="$body&hosted_dns_recordid=$_record_id"
@ -107,10 +132,14 @@ dns_he_rm() {
exit_code="$?" exit_code="$?"
if [ "$exit_code" -eq 0 ]; then if [ "$exit_code" -eq 0 ]; then
_info "Record removed successfully." _info "Record removed successfully."
if [ ! -z "$HE_OTP_Secret" ]; then
_sign_out _sign_out
fi
else else
_err "Could not clean (remove) up the record. Please go to HE administration interface and clean it by hand." _err "Could not clean (remove) up the record. Please go to HE administration interface and clean it by hand."
if [ ! -z "$HE_OTP_Secret" ]; then
_sign_out _sign_out
fi
return "$exit_code" return "$exit_code"
fi fi
} }
@ -124,7 +153,7 @@ dns_he_rm() {
_sign_in() { _sign_in() {
_debug "Signing into Hurricane Electric account." _debug "Signing into Hurricane Electric account."
body="email=${HE_Username}&pass=${HE_Password}&submit=Login%21" body="email=${HE_Username}&pass=${HE_Password}"
response="$(_post "$body" "https://dns.he.net/")" response="$(_post "$body" "https://dns.he.net/")"
@ -177,6 +206,10 @@ _find_zone() {
_domain="$1" _domain="$1"
if [ -z "$HE_OTP_Secret" ]; then
body="email=${HE_Username}&pass=${HE_Password}"
fi
_matches=$(_post "$body" "https://dns.he.net/" \ _matches=$(_post "$body" "https://dns.he.net/" \
| _egrep_o "delete_dom.*name=\"[^\"]+\" value=\"[0-9]+" | _egrep_o "delete_dom.*name=\"[^\"]+\" value=\"[0-9]+"
) )