| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """AuthHandler plugin for gsutil's boto to support LOAS based auth.""" | 5 """AuthHandler plugin for gsutil's boto to support LOAS based auth.""" |
| 6 | 6 |
| 7 import getpass | 7 import getpass |
| 8 import json | 8 import json |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import subprocess | 11 import subprocess |
| 12 import time | 12 import time |
| 13 import urllib2 | 13 import urllib2 |
| 14 | 14 |
| 15 from boto.auth_handler import AuthHandler | 15 from boto.auth_handler import AuthHandler |
| 16 from boto.auth_handler import NotReadyToAuthenticate | 16 from boto.auth_handler import NotReadyToAuthenticate |
| 17 | 17 |
| 18 CMD = ['stubby', '--proto2', 'call', 'blade:sso', 'CorpLogin.Exchange'] | 18 CMD = ['stubby', '--proto2', 'call', 'blade:sso', 'CorpLogin.Exchange'] |
| 19 | 19 |
| 20 STUBBY_CMD = """target: { | 20 STUBBY_CMD = """target: { |
| 21 scope: GAIA_USER | 21 scope: GAIA_USER |
| 22 name: "%s" | 22 name: "%s" |
| 23 } | 23 } |
| 24 target_credential: { | 24 target_credential: { |
| 25 type: OAUTH2_TOKEN | 25 type: OAUTH2_TOKEN |
| 26 oauth2_attributes: { | 26 oauth2_attributes: { |
| 27 scope: 'https://www.googleapis.com/auth/devstorage.read_only' | 27 scope: 'https://www.googleapis.com/auth/devstorage.read_write' |
| 28 } | 28 } |
| 29 }""" | 29 }""" |
| 30 | 30 |
| 31 COOKIE_LOCATION = os.path.expanduser('~/.devstore_token') | 31 COOKIE_LOCATION = os.path.expanduser('~/.devstore_token') |
| 32 | 32 |
| 33 TOKEN_EXPIRY = 300 | 33 TOKEN_EXPIRY = 300 |
| 34 | 34 |
| 35 | 35 |
| 36 class SSOAuthError(Exception): | 36 class SSOAuthError(Exception): |
| 37 pass | 37 pass |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 def add_auth(self, http_request): | 96 def add_auth(self, http_request): |
| 97 http_request.headers['Authorization'] = 'OAuth %s' % self.GetAccessToken() | 97 http_request.headers['Authorization'] = 'OAuth %s' % self.GetAccessToken() |
| 98 | 98 |
| 99 @staticmethod | 99 @staticmethod |
| 100 def has_prodaccess(): | 100 def has_prodaccess(): |
| 101 for path in os.environ['PATH'].split(os.pathsep): | 101 for path in os.environ['PATH'].split(os.pathsep): |
| 102 exe_file = os.path.join(path, 'prodaccess') | 102 exe_file = os.path.join(path, 'prodaccess') |
| 103 if os.path.exists(exe_file) and os.access(exe_file, os.X_OK): | 103 if os.path.exists(exe_file) and os.access(exe_file, os.X_OK): |
| 104 return True | 104 return True |
| 105 return False | 105 return False |
| OLD | NEW |