How to use the conf/conf.httpOnly function in conf

To help you get started, we’ve selected a few conf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github misterfresh / react-without-webpack / app / api / api.js View on Github external
headers = Object.assign({}, headers, {
      'X-Request-Id': uuid(),
      Accept: 'application/json',
      'Content-Type': 'application/json'
    })
    if (
      typeof require !== 'undefined' &&
      typeof this.token !== 'undefined' &&
      !!this.token
    ) {
      let cookieConf = require('conf/conf')
      Object.assign(headers, {
        Cookie: !!this.token
          ? `${cookieConf.name}_token=${this
              .token}; Max-Age=${cookieConf.maxAge}; Domain=${cookieConf.domain}; Path=${cookieConf.path};${cookieConf.httpOnly
              ? ' httpOnly;'
              : ''}${cookieConf ? 'Secure;' : ''}`
          : false
      })
    }
    options = Object.assign({}, options, {
      headers
    })
    if (typeof require !== 'undefined') {
      Object.assign(options, { agent: require('middleware/auth/agent') })
    }

    return fetch(url, options)
      .then(this.checkStatus)
      .then(this.buildResponse.bind(this, url))
      .catch(this.manageError)
github misterfresh / react-without-webpack / middleware / auth / auth-middleware.js View on Github external
return stackTokenCalls(req, ip).spread((user, token) => {

    let options = Object.assign(
      {},
      {
        maxAge: conf.maxAge,
        path: conf.path
      },
      conf.domain && {
        domain: conf.domain
      },
      conf.secure && {
        secure: conf.secure
      },
      conf.httpOnly && {
        httpOnly: conf.httpOnly
      }
    )

    if (token) {
      res.cookie(`${conf.name}_token`, token, options)
    }
    req.user = user.data
    req.token = token
    return next()
  })
}
github misterfresh / react-without-webpack / middleware / auth / auth-middleware.js View on Github external
return stackTokenCalls(req, ip).spread((user, token) => {

    let options = Object.assign(
      {},
      {
        maxAge: conf.maxAge,
        path: conf.path
      },
      conf.domain && {
        domain: conf.domain
      },
      conf.secure && {
        secure: conf.secure
      },
      conf.httpOnly && {
        httpOnly: conf.httpOnly
      }
    )

    if (token) {
      res.cookie(`${conf.name}_token`, token, options)
    }
    req.user = user.data
    req.token = token
    return next()
  })
}