Browse Source

Adapt to use general naming rule for account variables.

cron
Armando Lüscher 8 years ago
parent
commit
afa3fc8bf9
No known key found for this signature in database GPG Key ID: 3D71085D14920359
  1. 8
      dnsapi/README.md
  2. 34
      dnsapi/dns_cyon.sh

8
dnsapi/README.md

@ -311,9 +311,9 @@ You only need to set your cyon.ch login credentials.
If you also have 2 Factor Authentication (OTP) enabled, you need to set your secret token too and have `oathtool` installed. If you also have 2 Factor Authentication (OTP) enabled, you need to set your secret token too and have `oathtool` installed.
``` ```
export cyon_username="your_cyon_username"
export cyon_password="your_cyon_password"
export cyon_otp_secret="your_otp_secret" # Only required if using 2FA
export CY_Username="your_cyon_username"
export CY_Password="your_cyon_password"
export CY_OTP_Secret="your_otp_secret" # Only required if using 2FA
``` ```
To issue a cert: To issue a cert:
@ -321,7 +321,7 @@ To issue a cert:
acme.sh --issue --dns dns_cyon -d example.com -d www.example.com acme.sh --issue --dns dns_cyon -d example.com -d www.example.com
``` ```
The `cyon_username`, `cyon_password` and `cyon_otp_secret` will be saved in `~/.acme.sh/account.conf` and will be reused when needed.
The `CY_Username`, `CY_Password` and `CY_OTP_Secret` will be saved in `~/.acme.sh/account.conf` and will be reused when needed.
# Use custom API # Use custom API

34
dnsapi/dns_cyon.sh

@ -43,17 +43,17 @@ dns_cyon_rm() {
_cyon_load_credentials() { _cyon_load_credentials() {
# Convert loaded password to/from base64 as needed. # Convert loaded password to/from base64 as needed.
if [ "${cyon_password_b64}" ]; then
cyon_password="$(printf "%s" "${cyon_password_b64}" | _dbase64 "multiline")"
elif [ "${cyon_password}" ]; then
cyon_password_b64="$(printf "%s" "${cyon_password}" | _base64)"
if [ "${CY_Password_B64}" ]; then
CY_Password="$(printf "%s" "${CY_Password_B64}" | _dbase64 "multiline")"
elif [ "${CY_Password}" ]; then
CY_Password_B64="$(printf "%s" "${CY_Password}" | _base64)"
fi fi
if [ -z "${cyon_username}" ] || [ -z "${cyon_password}" ]; then
if [ -z "${CY_Username}" ] || [ -z "${CY_Password}" ]; then
# Dummy entries to satify script checker. # Dummy entries to satify script checker.
cyon_username=""
cyon_password=""
cyon_otp_secret=""
CY_Username=""
CY_Password=""
CY_OTP_Secret=""
_err "" _err ""
_err "You haven't set your cyon.ch login credentials yet." _err "You haven't set your cyon.ch login credentials yet."
@ -64,12 +64,12 @@ _cyon_load_credentials() {
# Save the login credentials to the account.conf file. # Save the login credentials to the account.conf file.
_debug "Save credentials to account.conf" _debug "Save credentials to account.conf"
_saveaccountconf cyon_username "${cyon_username}"
_saveaccountconf cyon_password_b64 "$cyon_password_b64"
if [ ! -z "${cyon_otp_secret}" ]; then
_saveaccountconf cyon_otp_secret "$cyon_otp_secret"
_saveaccountconf CY_Username "${CY_Username}"
_saveaccountconf CY_Password_B64 "$CY_Password_B64"
if [ ! -z "${CY_OTP_Secret}" ]; then
_saveaccountconf CY_OTP_Secret "$CY_OTP_Secret"
else else
_clearaccountconf cyon_otp_secret
_clearaccountconf CY_OTP_Secret
fi fi
} }
@ -140,8 +140,8 @@ _cyon_get_cookie_header() {
_cyon_login() { _cyon_login() {
_info " - Logging in..." _info " - Logging in..."
username_encoded="$(printf "%s" "${cyon_username}" | _cyon_urlencode)"
password_encoded="$(printf "%s" "${cyon_password}" | _cyon_urlencode)"
username_encoded="$(printf "%s" "${CY_Username}" | _cyon_urlencode)"
password_encoded="$(printf "%s" "${CY_Password}" | _cyon_urlencode)"
login_url="https://my.cyon.ch/auth/index/dologin-async" login_url="https://my.cyon.ch/auth/index/dologin-async"
login_data="$(printf "%s" "username=${username_encoded}&password=${password_encoded}&pathname=%2F")" login_data="$(printf "%s" "username=${username_encoded}&password=${password_encoded}&pathname=%2F")"
@ -165,7 +165,7 @@ _cyon_login() {
# todo: instead of just checking if the env variable is defined, check if we actually need to do a 2FA auth request. # todo: instead of just checking if the env variable is defined, check if we actually need to do a 2FA auth request.
# 2FA authentication with OTP? # 2FA authentication with OTP?
if [ ! -z "${cyon_otp_secret}" ]; then
if [ ! -z "${CY_OTP_Secret}" ]; then
_info " - Authorising with OTP code..." _info " - Authorising with OTP code..."
if ! _exists oathtool; then if ! _exists oathtool; then
@ -175,7 +175,7 @@ _cyon_login() {
fi fi
# Get OTP code with the defined secret. # Get OTP code with the defined secret.
otp_code="$(oathtool --base32 --totp "${cyon_otp_secret}" 2>/dev/null)"
otp_code="$(oathtool --base32 --totp "${CY_OTP_Secret}" 2>/dev/null)"
login_otp_url="https://my.cyon.ch/auth/multi-factor/domultifactorauth-async" login_otp_url="https://my.cyon.ch/auth/multi-factor/domultifactorauth-async"
login_otp_data="totpcode=${otp_code}&pathname=%2F&rememberme=0" login_otp_data="totpcode=${otp_code}&pathname=%2F&rememberme=0"

Loading…
Cancel
Save