Browse Source

support and test old and new authn methods

pull/402/head
Mark Mercado 6 years ago
parent
commit
e235796865
2 changed files with 1218 additions and 7 deletions
  1. +7
    -7
      octodns/provider/cloudflare.py
  2. +1211
    -0
      tests/test_octodns_provider_cloudflare_no_email.py

+ 7
- 7
octodns/provider/cloudflare.py View File

@ -66,23 +66,23 @@ class CloudflareProvider(BaseProvider):
MIN_TTL = 120
TIMEOUT = 15
def __init__(self, id, token, email=None, cdn=False, *args, **kwargs):
def __init__(self, id, email=None, token=None, cdn=False, *args, **kwargs):
self.log = getLogger('CloudflareProvider[{}]'.format(id))
self.log.debug('__init__: id=%s, email=%s, token=***, cdn=%s', id,
email, cdn)
super(CloudflareProvider, self).__init__(id, *args, **kwargs)
sess = Session()
# https://api.cloudflare.com/#getting-started-requests
# https://tools.ietf.org/html/rfc6750#section-2.1
if not email:
if email and token:
sess.headers.update({
'Authorization': 'Bearer %s'.format(token),
'X-Auth-Email': email,
'X-Auth-Key': token,
})
else:
# https://api.cloudflare.com/#getting-started-requests
# https://tools.ietf.org/html/rfc6750#section-2.1
sess.headers.update({
'X-Auth-Email': email,
'X-Auth-Key': token,
'Authorization': 'Bearer %s'.format(token),
})
self.cdn = cdn
self._sess = sess


+ 1211
- 0
tests/test_octodns_provider_cloudflare_no_email.py
File diff suppressed because it is too large
View File


Loading…
Cancel
Save