Skip to content
This repository was archived by the owner on Jan 20, 2020. It is now read-only.

Commit 9ffe815

Browse files
author
Feng Honglin
authored
Merge pull request #19 from docker/not_permanently_cache_invalid_auth_header
CLOUD-3774 not permanently cache invalid auth header
2 parents 4325c7c + f78ac3a commit 9ffe815

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

dockercloud/api/base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,7 @@ class Triggerable(BasicObject):
267267

268268
class StreamingAPI(BasicObject):
269269
def __init__(self, url):
270-
self._ws_init(url)
271-
272-
def _ws_init(self, url):
273270
self.url = url
274-
275271
user_agent = 'python-dockercloud/%s' % dockercloud.__version__
276272
if dockercloud.user_agent:
277273
user_agent = "%s %s" % (dockercloud.user_agent, user_agent)

dockercloud/api/events.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ def __init__(self):
2121
else:
2222
url = "/".join([dockercloud.stream_host.rstrip("/"), "api", "audit", self._api_version,
2323
endpoint.lstrip("/")])
24-
self.invaid_auth_headers = set()
25-
self.auth_error = ""
2624
super(self.__class__, self).__init__(url)
2725

2826
def _on_message(self, ws, message):
@@ -39,15 +37,16 @@ def _on_message(self, ws, message):
3937

4038
def _on_error(self, ws, e):
4139
if isinstance(e, websocket._exceptions.WebSocketBadStatusException) and getattr(e, "status_code") == 401:
42-
self.auth_error = "Not Authorized"
43-
self.invaid_auth_headers.add(str(dockercloud.auth.get_auth_header()))
40+
self.auth_error = True
4441

4542
super(self.__class__, self)._on_error(ws, e)
4643

4744
def run_forever(self, *args, **kwargs):
4845
while True:
49-
if str(dockercloud.auth.get_auth_header()) in self.invaid_auth_headers:
50-
raise AuthError(self.auth_error)
46+
if self.auth_error:
47+
self.auth_error = False
48+
raise AuthError("Not Authorized")
49+
5150
ws = websocket.WebSocketApp(self.url, header=self.header,
5251
on_open=self._on_open,
5352
on_message=self._on_message,

0 commit comments

Comments
 (0)