INNER CODE UNIT · TypeScript

updateBucket

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

function updateBucket(loginAttempt: boolean, authConfig: AuthConfig, userIP?: string): void {
  // only fill buckets if the user tries to login
  if (userIP && loginAttempt) {
    if (!throttleBucket[userIP]) {
      throttleBucket[userIP] = [];
    }
    throttleBucket[userIP].push(new Date().getTime());

    // delete old requests. Just keep the latest {requestLimitWithinTime} requests
    if (throttleBucket[userIP].length > authConfig.nRequestWithinTime) {
      throttleBucket[userIP].shift();
    }
  }
}

/**
 *
 * @param ip. The IP of the request

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…