INNER CODE UNIT · TypeScript

setBasicAUTH

keptn/keptn · bridge/server/app.ts:126

async function setBasicAUTH(app: Express, auth: AuthConfig): Promise<void> {
  log.warning('Installing Basic authentication - please check environment variables!');

  setInterval(cleanIpBuckets, auth.cleanBucketIntervalMs);

  app.use((req, res, next) => {
    // parse login and password from headers
    const b64auth = (req.headers.authorization || '').split(' ')[1] || '';
    const [login, password] = Buffer.from(b64auth, 'base64').toString().split(':');
    let userIP = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
    userIP = userIP instanceof Array ? userIP[0] : userIP;

    if (userIP && isIPThrottled(userIP, auth)) {
      log.error('Request limit reached');
      res.status(429).send('Reached request limit');
      return;
    } else if (
      // if username and password are not set or wrong

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…