mirror of
https://github.com/thegeeklab/corenetworks.git
synced 2024-11-13 20:30:40 +00:00
add expires timestamp to the BasicAuth object
This commit is contained in:
parent
f2d705a994
commit
0bb59c7308
@ -1,2 +1,2 @@
|
||||
* BUGFIX
|
||||
* extend the workaround to ensure CNAME records could not mixed with other types using the same name
|
||||
* ENHANCEMENT
|
||||
* add `expires` timestamp to the BasicAuth object
|
||||
|
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Custom authenticators."""
|
||||
|
||||
import datetime
|
||||
import json
|
||||
|
||||
from requests import ConnectionError
|
||||
@ -19,7 +20,7 @@ class CoreNetworksBasicAuth(AuthBase):
|
||||
self.user = user
|
||||
self.password = password
|
||||
self.endpoint = endpoint
|
||||
self.token = self._login()
|
||||
self.token, self.expires = self._login()
|
||||
|
||||
def __eq__(self, other): # noqa
|
||||
return all([
|
||||
@ -60,8 +61,10 @@ class CoreNetworksBasicAuth(AuthBase):
|
||||
raise
|
||||
|
||||
response = handle.json()
|
||||
token = response["token"]
|
||||
expires = datetime.datetime.now() + datetime.timedelta(seconds=response["expires"])
|
||||
|
||||
return response["token"]
|
||||
return token, expires
|
||||
|
||||
|
||||
class CoreNetworksTokenAuth(AuthBase):
|
||||
|
Loading…
Reference in New Issue
Block a user