OLD | NEW |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 """Defines class Rietveld to easily access a rietveld instance. | 5 """Defines class Rietveld to easily access a rietveld instance. |
6 | 6 |
7 Security implications: | 7 Security implications: |
8 | 8 |
9 The following hypothesis are made: | 9 The following hypothesis are made: |
10 - Rietveld enforces: | 10 - Rietveld enforces: |
(...skipping 29 matching lines...) Expand all Loading... | |
40 self.email = email | 40 self.email = email |
41 self.password = password | 41 self.password = password |
42 if email and password: | 42 if email and password: |
43 get_creds = lambda: (email, password) | 43 get_creds = lambda: (email, password) |
44 self.rpc_server = upload.HttpRpcServer( | 44 self.rpc_server = upload.HttpRpcServer( |
45 self.url, | 45 self.url, |
46 get_creds, | 46 get_creds, |
47 extra_headers=extra_headers or {}) | 47 extra_headers=extra_headers or {}) |
48 else: | 48 else: |
49 if email == '': | 49 if email == '': |
50 # If email is given as an empty string, then assume we want to make | |
51 # requests that do not need authentication. Bypass authentication by | |
52 # setting the flag to True. | |
50 get_creds = lambda: (email, None) | 53 get_creds = lambda: (email, None) |
51 self.rpc_server = upload.HttpRpcServer(url, get_creds) | 54 self.rpc_server = upload.HttpRpcServer(url, get_creds) |
55 self.rpc_server.authenticated = True | |
M-A Ruel
2012/09/03 17:34:25
My fault in removing it in r154696.
Roger Tawa OOO till Jul 10th
2012/09/04 13:48:31
:-) I thought you had figured out a better way to
M-A Ruel
2012/09/04 17:36:29
No, it still did prompts without it. :/
| |
52 else: | 56 else: |
53 self.rpc_server = upload.GetRpcServer(url, email) | 57 self.rpc_server = upload.GetRpcServer(url, email) |
54 | 58 |
55 self._xsrf_token = None | 59 self._xsrf_token = None |
56 self._xsrf_token_time = None | 60 self._xsrf_token_time = None |
57 | 61 |
58 def xsrf_token(self): | 62 def xsrf_token(self): |
59 if (not self._xsrf_token_time or | 63 if (not self._xsrf_token_time or |
60 (time.time() - self._xsrf_token_time) > 30*60): | 64 (time.time() - self._xsrf_token_time) > 30*60): |
61 self._xsrf_token_time = time.time() | 65 self._xsrf_token_time = time.time() |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 if not 'Name or service not known' in e.reason: | 345 if not 'Name or service not known' in e.reason: |
342 # Usually internal GAE flakiness. | 346 # Usually internal GAE flakiness. |
343 raise | 347 raise |
344 # If reaching this line, loop again. Uses a small backoff. | 348 # If reaching this line, loop again. Uses a small backoff. |
345 time.sleep(1+maxtries*2) | 349 time.sleep(1+maxtries*2) |
346 finally: | 350 finally: |
347 upload.ErrorExit = old_error_exit | 351 upload.ErrorExit = old_error_exit |
348 | 352 |
349 # DEPRECATED. | 353 # DEPRECATED. |
350 Send = get | 354 Send = get |
OLD | NEW |