Skip to content

Commit

Permalink
Store Rackspace DNSAPI in domain conf
Browse files Browse the repository at this point in the history
This is meant to address acmesh-official#799 and acmesh-official#2091
  • Loading branch information
Chris committed Aug 4, 2020
1 parent 40cda92 commit 3df276c
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions dnsapi/dns_rackspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
#
#
#RACKSPACE_Username=""
#
#RACKSPACE_Apikey=""

RACKSPACE_Endpoint="https://dns.api.rackspacecloud.com/v1.0"

# 20200723 - changed saving read/save account conf to read/save domain conf for api creds
# 20190213 - The name & id fields swapped in the API response; fix sed
# 20190101 - Duplicating file for new pull request to dev branch
# Original - tcocca:rackspace_dnsapi https://github.com/acmesh-official/acme.sh/pull/1297

######## Public functions #####################
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_rackspace_add() {
_debug $DOMAIN_CONF
fulldomain="$1"
_debug fulldomain="$fulldomain"
txtvalue="$2"
Expand Down Expand Up @@ -152,6 +153,29 @@ _rackspace_rest() {
return 0
}

_rackspace_check_auth() {
# retrieve the rackspace creds
RACKSPACE_Username="${RACKSPACE_Username:-$(_readdomainconf RACKSPACE_Username)}"
RACKSPACE_Apikey="${RACKSPACE_Apikey:-$(_readdomainconf RACKSPACE_Apikey)}"
# check their vals for null
if [ -z "$RACKSPACE_Username" ] || [ -z "$RACKSPACE_Apikey" ]; then
RACKSPACE_Username=""
RACKSPACE_Apikey=""
_err "You didn't specify a Rackspace username and api key."
_err "Please set those values and try again."
return 1
fi
# save the username and api key to the domain conf file.
_savedomainconf RACKSPACE_Username "$RACKSPACE_Username"
_savedomainconf RACKSPACE_Apikey "$RACKSPACE_Apikey"
if [ -z "$RACKSPACE_Token" ]; then
_info "Getting authorization token."
if ! _rackspace_authorization; then
_err "Can not get token."
fi
fi
}

_rackspace_authorization() {
export _H1="Content-Type: application/json"
data="{\"auth\":{\"RAX-KSKEY:apiKeyCredentials\":{\"username\":\"$RACKSPACE_Username\",\"apiKey\":\"$RACKSPACE_Apikey\"}}}"
Expand All @@ -172,29 +196,6 @@ _rackspace_authorization() {
return 0
}

_rackspace_check_auth() {
# retrieve the rackspace creds
RACKSPACE_Username="${RACKSPACE_Username:-$(_readaccountconf_mutable RACKSPACE_Username)}"
RACKSPACE_Apikey="${RACKSPACE_Apikey:-$(_readaccountconf_mutable RACKSPACE_Apikey)}"
# check their vals for null
if [ -z "$RACKSPACE_Username" ] || [ -z "$RACKSPACE_Apikey" ]; then
RACKSPACE_Username=""
RACKSPACE_Apikey=""
_err "You didn't specify a Rackspace username and api key."
_err "Please set those values and try again."
return 1
fi
# save the username and api key to the account conf file.
_saveaccountconf_mutable RACKSPACE_Username "$RACKSPACE_Username"
_saveaccountconf_mutable RACKSPACE_Apikey "$RACKSPACE_Apikey"
if [ -z "$RACKSPACE_Token" ]; then
_info "Getting authorization token."
if ! _rackspace_authorization; then
_err "Can not get token."
fi
fi
}

_rackspace_check_rootzone() {
_debug "First detect the root zone"
if ! _get_root_zone "$fulldomain"; then
Expand Down

0 comments on commit 3df276c

Please sign in to comment.