Get the connection details for calling Vault, from local configuration if
    it exists, or from the master otherwise
978752
def get_vault_connection():
    '''
    
    '''
    def _use_local_config():
        log.debug('Using Vault connection details from local config')
        try:
            if __opts__['vault']['auth']['method'] == 'approle':
                verify = __opts__['vault'].get('verify', None)
                if _selftoken_expired():
                    log.debug('Vault token expired. Recreating one')
                    # Requesting a short ttl token
                    url = '{0}/v1/auth/approle/login'.format(__opts__['vault']['url'])
                    payload = {'role_id': __opts__['vault']['auth']['role_id']}
                    if 'secret_id' in __opts__['vault']['auth']:
                        payload['secret_id'] = __opts__['vault']['auth']['secret_id']
                    response = requests.post(url, json=payload, verify=verify)
                    if response.status_code != 200:
                        errmsg = 'An error occured while getting a token from approle'
                        raise salt.exceptions.CommandExecutionError(errmsg)
                    __opts__['vault']['auth']['token'] = response.json()['auth']['client_token']
            if __opts__['vault']['auth']['method'] == 'wrapped_token':
                verify = __opts__['vault'].get('verify', None)
                if _wrapped_token_valid():
                    url = '{0}/v1/sys/wrapping/unwrap'.format(__opts__['vault']['url'])
                    headers = {'X-Vault-Token': __opts__['vault']['auth']['token']}
                    response = requests.post(url, headers=headers, verify=verify)
                    if response.status_code != 200:
                        errmsg = 'An error occured while unwrapping vault token'
                        raise salt.exceptions.CommandExecutionError(errmsg)
                    __opts__['vault']['auth']['token'] = response.json()['auth']['client_token']
            return {
                'url': __opts__['vault']['url'],
                'token': __opts__['vault']['auth']['token'],
                'verify': __opts__['vault'].get('verify', None)
            }
        except KeyError as err:
            errmsg = 'Minion has "vault" config section, but could not find key "{0}" within'.format(err.message)
            raise salt.exceptions.CommandExecutionError(errmsg)

    if 'vault' in __opts__ and __opts__.get('__role', 'minion') == 'master':
        if 'id' in __grains__:
            log.debug('Contacting master for Vault connection details')
            return _get_token_and_url_from_master()
        else:
            return _use_local_config()
    elif any((__opts__['local'], __opts__['file_client'] == 'local', __opts__['master_type'] == 'disable')):
        return _use_local_config()
    else:
        log.debug('Contacting master for Vault connection details')
        return _get_token_and_url_from_master()
994220
def get_connection_by_name(self, name):
        ''''''
        with self._mutex:
            for conn in self.connections:
                if conn.name == name:
                    return conn
            return None
124018
def _get_authz_session(self):
        
        from ..utilities import BOOTSTRAP_VAULT_TYPE
        try:
            vaults = self._get_vault_lookup_session().get_vaults_by_genus_type(BOOTSTRAP_VAULT_TYPE)
        except Unimplemented:
            return self._get_authz_manager().get_authorization_session()
        if vaults.available():
            vault = vaults.next()
            return self._get_authz_manager().get_authorization_session_for_vault(vault.get_id())
        else:
            return self._get_authz_manager().get_authorization_session()
385425
def get_default_connection():
  
  tid = id(threading.current_thread())
  conn = _conn_holder.get(tid)
  if not conn:
    with(_rlock):
      # No other thread would insert a value in our slot, so no need
      # to recheck existence inside the lock.
      if 'project_endpoint' not in _options and 'project_id' not in _options:
        _options['project_endpoint'] = helper.get_project_endpoint_from_env()
      if 'credentials' not in _options:
        _options['credentials'] = helper.get_credentials_from_env()
      # We still need the lock when caching the thread local connection so we
      # don't race with _conn_holder.clear() in set_options().
      _conn_holder[tid] = conn = connection.Datastore(**_options)
  return conn
1355303
def get_conn_info(self):
        from sockjs.cyclone.conn import ConnectionInfo

        
        return ConnectionInfo(self.request.remote_ip,
                              self.request.cookies,
                              self.request.arguments,
                              self.request.headers,
                              self.request.path)
539456
def read(self, client):
        """"""
        val = None
        if self.no_resource:
            return val

        LOG.debug("Reading from %s", self)
        try:
            val = client.read(self.path)
        except hvac.exceptions.InvalidRequest as vault_exception:
            if str(vault_exception).startswith('no handler for route'):
                val = None

        return val
1193432
def get_all
      raise yellow(
        "Vault prefix: '#{prefix}' does not exist, or doesn't contain any secrets to pull/check"\
        "\nEnsure mount is enabled and use `sanctum create`, and `sanctum push` to add secrets"
      ) if invalid_prefix?

      secrets_from_vault = Hash.new
      secrets_from_vault[prefix] = JSON(list_recursive(list_prefix).to_json)
      secrets_from_vault
    end
73941
def get_vault_form(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinAdminSession.get_bin_form_for_update_template
        # This method might be a bit sketchy. Time will tell.
        if isinstance(args[-1], list) or 'vault_record_types' in kwargs:
            return self.get_vault_form_for_create(*args, **kwargs)
        else:
            return self.get_vault_form_for_update(*args, **kwargs)
1370892
function getVcl(conf) {
  const config = _.extend({
    version: new Date().toISOString(),
    timeout: defaultTimeout,
    urlPassList: ['cache-control=no-cache'],
    hash: [
      'req.url',
      [
        'req.http.host',
        'server.ip',
      ],
    ],
    hisForPassTTL: 120,
  }, conf);
  /* istanbul ignore if */
  if (!config.directors || !config.name) {
    throw new Error('directors, name can not be null');
  }
  if (!config.directors.length) {
    throw new Error('directors can not be empty');
  }
  if (config.name === '$HOSTNAME') {
    config.name = os.hostname();
  } else if (config.name[0] === '$') {
    config.name = process.env[config.name.substring(1)];
  }
  _.forEach(config.directors, (item) => {
    if (!item.timeout) {
      /* eslint no-param-reassign:0 */
      item.timeout = config.timeout;
    }
    if (item.type === 'shard') {
      throw new Error('shard director is not support');
    }
  });
  const cloneConfig = _.extend({
    stale: 3,
    varnish: '5',
    hashConfig: getHash(config.hash),
    passRules: getPassRules(config.urlPassList),
  }, config);
  return getConfig(cloneConfig.directors).then((data) => {
    _.extend(cloneConfig, data);
    return readFilePromise(path.join(__dirname, 'template/varnish.tpl'));
  }).then(tpl => _.template(tpl)(cloneConfig));
}
28225
def _get_conn(key=None,
              keyid=None,
              profile=None,
              region=None,
              **kwargs):
    '''
    
    '''
    client = None
    if profile:
        if isinstance(profile, six.string_types):
            if profile in __pillar__:
                profile = __pillar__[profile]
            elif profile in __opts__:
                profile = __opts__[profile]
    elif key or keyid or region:
        profile = {}
        if key:
            profile['key'] = key
        if keyid:
            profile['keyid'] = keyid
        if region:
            profile['region'] = region

    if isinstance(profile, dict):
        if 'region' in profile:
            profile['region_name'] = profile['region']
            profile.pop('region', None)
        if 'key' in profile:
            profile['aws_secret_access_key'] = profile['key']
            profile.pop('key', None)
        if 'keyid' in profile:
            profile['aws_access_key_id'] = profile['keyid']
            profile.pop('keyid', None)

        client = boto3.client('efs', **profile)
    else:
        client = boto3.client('efs')

    return client
1062230
def _get_proxy_connection_details():
    '''
    
    '''
    proxytype = get_proxy_type()
    if proxytype == 'esxi':
        details = __salt__['esxi.get_details']()
    elif proxytype == 'esxcluster':
        details = __salt__['esxcluster.get_details']()
    elif proxytype == 'esxdatacenter':
        details = __salt__['esxdatacenter.get_details']()
    elif proxytype == 'vcenter':
        details = __salt__['vcenter.get_details']()
    elif proxytype == 'esxvm':
        details = __salt__['esxvm.get_details']()
    else:
        raise CommandExecutionError('\'{0}\' proxy is not supported'
                                    ''.format(proxytype))
    return \
            details.get('vcenter') if 'vcenter' in details \
            else details.get('host'), \
            details.get('username'), \
            details.get('password'), details.get('protocol'), \
            details.get('port'), details.get('mechanism'), \
            details.get('principal'), details.get('domain')
1356566
def read_data(item, parent = '')
      me = File.join(parent, item)

      # me will contain /metadata if secrets_version 2 due to list_prefix method
      if secrets_version == "2"
        me = me.sub(/metadata/, "data")
        # It's possible for a vault secret to be nil...
        if vault_client.logical.read(me).nil?
          warn red("vault secret '#{me}' contains a null vaule, ignoring...")
          {}
        else
          vault_client.logical.read(me).data[:data]
        end
      else
        vault_client.logical.read(me).data
      end
    end
792571
def extract_file_args(subparsers):
    """"""
    extract_parser = subparsers.add_parser('extract_file',
                                           help='Extract a single secret from'
                                           'Vault to a local file')
    extract_parser.add_argument('vault_path',
                                help='Full path (including key) to secret')
    extract_parser.add_argument('destination',
                                help='Location of destination file')
    base_args(extract_parser)
245300
def maybe_details(resource, opt):
    """"""

    if opt.verbose == 0:
        return

    if not resource.present:
        return

    obj = None
    existing = None
    if isinstance(resource, Resource):
        obj = resource.obj()
        existing = resource.existing
    elif isinstance(resource, VaultBackend):
        obj = resource.config
        existing = resource.existing

    if not obj:
        return

    if is_unicode(existing) and is_unicode(obj):
        a_diff = difflib.unified_diff(existing.splitlines(),
                                      obj.splitlines(),
                                      lineterm='')
        for line in a_diff:
            if line.startswith('+++') or line.startswith('---'):
                continue
            if line[0] == '+':
                print(maybe_colored("++ %s" % line[1:], 'green', opt))
            elif line[0] == '-':
                print(maybe_colored("-- %s" % line[1:], 'red', opt))
            else:
                print(line)
    elif isinstance(existing, dict):
        ignore_missing = isinstance(resource, VaultBackend)
        details_dict(obj, existing, ignore_missing, opt)
716503
def format_key_vault_credential_settings(result):
    '''
    
    '''
    from collections import OrderedDict
    # Only display parameters that have content
    order_dict = OrderedDict()
    if result.enable is not None:
        order_dict['enable'] = result.enable
    if result.credential_name is not None:
        order_dict['credentialName'] = result.credential_name
    if result.azure_key_vault_url is not None:
        order_dict['azureKeyVaultUrl'] = result.azure_key_vault_url

    return order_dict
52859
def pool
      @lock.synchronize do
        return @nhp if @nhp

        @nhp = PersistentHTTP.new("vault-ruby", nil, pool_size)

        if proxy_address
          proxy_uri = URI.parse "http://#{proxy_address}"

          proxy_uri.port = proxy_port if proxy_port

          if proxy_username
            proxy_uri.user = proxy_username
            proxy_uri.password = proxy_password
          end

          @nhp.proxy = proxy_uri
        end

        # Use a custom open timeout
        if open_timeout || timeout
          @nhp.open_timeout = (open_timeout || timeout).to_i
        end

        # Use a custom read timeout
        if read_timeout || timeout
          @nhp.read_timeout = (read_timeout || timeout).to_i
        end

        @nhp.verify_mode = OpenSSL::SSL::VERIFY_PEER

        # Vault requires TLS1.2
        @nhp.ssl_version = "TLSv1_2"

        # Only use secure ciphers
        @nhp.ciphers = ssl_ciphers

        # Custom pem files, no problem!
        pem = ssl_pem_contents || (ssl_pem_file ? File.read(ssl_pem_file) : nil)
        if pem
          @nhp.cert = OpenSSL::X509::Certificate.new(pem)
          @nhp.key = OpenSSL::PKey::RSA.new(pem, ssl_pem_passphrase)
        end

        # Use custom CA cert for verification
        if ssl_ca_cert
          @nhp.ca_file = ssl_ca_cert
        end

        # Use custom CA path that contains CA certs
        if ssl_ca_path
          @nhp.ca_path = ssl_ca_path
        end

        if ssl_cert_store
          @nhp.cert_store = ssl_cert_store
        end

        # Naughty, naughty, naughty! Don't blame me when someone hops in
        # and executes a MITM attack!
        if !ssl_verify
          @nhp.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end

        # Use custom timeout for connecting and verifying via SSL
        if ssl_timeout || timeout
          @nhp.ssl_timeout = (ssl_timeout || timeout).to_i
        end

        @nhp
      end
    end
1317927
def get_conn_info(self):
        """"""
        return session.ConnectionInfo(self.request.remote_ip,
                                      self.request.cookies,
                                      self.request.arguments,
                                      self.request.headers,
                                      self.request.path)