support and test old and new authn methods

This commit is contained in:
Mark Mercado
2019-09-28 08:57:54 -04:00
parent 16121be4de
commit e235796865
2 changed files with 1219 additions and 8 deletions
+8 -8
View File
@@ -66,24 +66,24 @@ 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:
sess.headers.update({
'Authorization': 'Bearer %s'.format(token),
})
else:
if email and token:
sess.headers.update({
'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({
'Authorization': 'Bearer %s'.format(token),
})
self.cdn = cdn
self._sess = sess
File diff suppressed because it is too large Load Diff