def __init__(self, path, config, provider): self.service_account = config.get('GoogleCompute', 'service_account', '') if provider.name == 'google' and self.service_account: self.scopes = self.__GetGSScopes() if not self.scopes: raise NotReadyToAuthenticate() else: raise NotReadyToAuthenticate()
def __init__(self, path, config, provider): # Provider here is a boto.provider.Provider object (as opposed to the # provider attribute of CloudApi objects, which is a string). if provider.name != 'google': # Devshell credentials are valid for Google only and can't be used for s3. raise NotReadyToAuthenticate() try: self.creds = devshell.DevshellCredentials() except: raise NotReadyToAuthenticate()
def __init__(self, path, config, provider): if provider.name == 'google' and self.has_prodaccess(): # If we don't have a loas token, then bypass this auth handler. if subprocess.call(['loas_check', '-loas_check_retry_attempts=0'], stdout=subprocess.PIPE, stderr=subprocess.PIPE): raise NotReadyToAuthenticate() else: raise NotReadyToAuthenticate() self.token = None self.expire = 0
def __init__(self, path, config, provider): if (provider.name == 'google' and config.has_option( 'Credentials', 'gs_oauth2_refresh_token')): self.oauth2_client = oauth2_helper.OAuth2ClientFromBotoConfig( config) else: raise NotReadyToAuthenticate()
def __init__(self, path, config, provider): if provider.name == 'google': self.oauth2_client = gcs_oauth2_boto_plugin.oauth2_client.OAuth2JsonServiceAccountClient(provider.get_json_credentials()) global IS_SERVICE_ACCOUNT IS_SERVICE_ACCOUNT = True else: raise NotReadyToAuthenticate()
def __init__(self, path, config, provider): json_key = None if provider.name == 'google' and os.environ.get('GOOGLE_OAUTH2_JSON_PRIVATE_KEY'): try: json_key = json.loads(os.environ.get('GOOGLE_OAUTH2_JSON_PRIVATE_KEY')) except ValueError: pass if json_key is None: raise NotReadyToAuthenticate() token_cache = FileSystemTokenCache() proxy_host = None proxy_port = None proxy_user = None proxy_pass = None if config.has_option('Boto', 'proxy') and config.has_option('Boto', 'proxy_port'): proxy_host = config.get('Boto', 'proxy') proxy_port = int(config.get('Boto', 'proxy_port')) proxy_user = config.get('Boto', 'proxy_user', None) proxy_pass = config.get('Boto', 'proxy_pass', None) self.oauth2_client = OAuth2JsonServiceAccountClient( json_key, access_token_cache=token_cache, auth_uri=GOOGLE_OAUTH2_PROVIDER_AUTHORIZATION_URI, token_uri=GOOGLE_OAUTH2_PROVIDER_TOKEN_URI, disable_ssl_certificate_validation=not(config.getbool('Boto', 'https_validate_certificates', True)), proxy_host=proxy_host, proxy_port=proxy_port, proxy_user=proxy_user, proxy_pass=proxy_pass)
def add_auth(self, http_request): user = users.get_current_user() credentials = StorageByKeyName( Credentials, user.user_id(), 'credentials').get() if not credentials or credentials.invalid: raise NotReadyToAuthenticate() http_request.headers['Authorization'] = ( 'Bearer %s' % str(credentials.access_token))
def __init__(self, path, config, provider): self.oauth2_client = None if (provider.name == 'google'): if config.has_option('Credentials', 'gs_oauth2_refresh_token'): self.oauth2_client = oauth2_helper.OAuth2ClientFromBotoConfig( config) elif config.has_option('GoogleCompute', 'service_account'): self.oauth2_client = oauth2_client.CreateOAuth2GCEClient() if not self.oauth2_client: raise NotReadyToAuthenticate()
def __init__(self, path, config, provider): if (provider.name == 'google' and config.has_option('Credentials', 'gs_service_key_file')): self.oauth2_client = oauth2_helper.OAuth2ClientFromBotoConfig( config, cred_type=oauth2_client.CredTypes.OAUTH2_SERVICE_ACCOUNT) # If we make it to this point, then we will later attempt to authenticate # as a service account based on how the boto auth plugins work. This is # global so that command.py can access this value once it's set. # TODO: replace this approach with a way to get the current plugin # from boto so that we don't have to have global variables. global IS_SERVICE_ACCOUNT IS_SERVICE_ACCOUNT = True else: raise NotReadyToAuthenticate()
def __init__(self, path, config, provider): try: self.creds = devshell.DevshellCredentials() except: raise NotReadyToAuthenticate()
def __init__(self, path, config, provider): if provider.name != 'google': raise NotReadyToAuthenticate()