Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: third_party/gsutil/plugins/sso_auth.py

Issue 148203012: Allow prodaccess based gsutil to also write into a bucket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698