| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """OAuth2 related utilities and implementation of browser based login flow.""" | 5 """OAuth2 related utilities and implementation of browser based login flow.""" |
| 6 | 6 |
| 7 # pylint: disable=W0613 | 7 # pylint: disable=W0613 |
| 8 | 8 |
| 9 import base64 | 9 import base64 |
| 10 import BaseHTTPServer | 10 import BaseHTTPServer |
| 11 import collections | 11 import collections |
| 12 import datetime | 12 import datetime |
| 13 import json | 13 import json |
| 14 import logging | 14 import logging |
| 15 import optparse | 15 import optparse |
| 16 import os | 16 import os |
| 17 import socket | 17 import socket |
| 18 import sys | 18 import sys |
| 19 import threading | 19 import threading |
| 20 import time | 20 import time |
| 21 import urllib | 21 import urllib |
| 22 import urlparse | 22 import urlparse |
| 23 import webbrowser | 23 import webbrowser |
| 24 | 24 |
| 25 # All libraries here expect to find themselves in sys.path. | 25 # All libraries here expect to find themselves in sys.path. |
| 26 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 26 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath( |
| 27 __file__.decode(sys.getfilesystemencoding())))) |
| 27 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party')) | 28 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party')) |
| 28 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party', 'pyasn1')) | 29 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party', 'pyasn1')) |
| 29 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party', 'rsa')) | 30 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party', 'rsa')) |
| 30 | 31 |
| 31 import httplib2 | 32 import httplib2 |
| 32 import rsa | 33 import rsa |
| 33 | 34 |
| 34 from pyasn1.codec.der import decoder | 35 from pyasn1.codec.der import decoder |
| 35 from pyasn1.type import univ | 36 from pyasn1.type import univ |
| 36 | 37 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 self.end_headers() | 593 self.end_headers() |
| 593 query = self.path.split('?', 1)[-1] | 594 query = self.path.split('?', 1)[-1] |
| 594 query = dict(urlparse.parse_qsl(query)) | 595 query = dict(urlparse.parse_qsl(query)) |
| 595 self.server.query_params = query | 596 self.server.query_params = query |
| 596 self.wfile.write('<html><head><title>Authentication Status</title></head>') | 597 self.wfile.write('<html><head><title>Authentication Status</title></head>') |
| 597 self.wfile.write('<body><p>The authentication flow has completed.</p>') | 598 self.wfile.write('<body><p>The authentication flow has completed.</p>') |
| 598 self.wfile.write('</body></html>') | 599 self.wfile.write('</body></html>') |
| 599 | 600 |
| 600 def log_message(self, _format, *args): | 601 def log_message(self, _format, *args): |
| 601 """Do not log messages to stdout while running as command line program.""" | 602 """Do not log messages to stdout while running as command line program.""" |
| OLD | NEW |