AI Powered SaaS: Stripe + Auth + Billing + Deploy · Ders

İstek Hızı Sınırlama ve Kaba Kuvvet Saldırısı Koruması

Redis gibi hızlı bir veri deposuyla istek hızı sınırlama, hesap kilitleme ve üstel geri çekilme kullanarak SaaS kimlik doğrulamanızı ve API'lerinizi kötüye kullanıma karşı koruyun.

4. ders / 413 adım

İstek Hızı Sınırlama ve Kaba Kuvvet Saldırısı Koruması, CoddyKit'te ücretsiz bir AI Powered SaaS: Stripe + Auth + Billing + Deploy dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, AI Powered SaaS: Stripe + Auth + Billing + Deploy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. AI Powered SaaS: Stripe + Auth + Billing + Deploy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Why Rate Limit?

Without limits, attackers can hammer your login endpoint to guess passwords, scrape data, or run up costs on metered APIs. Rate limiting caps how many requests a client can make in a window.

Identifying the Client

Limits are keyed on something that identifies the caller: an IP address, a user ID, or an API key. Choose the key based on what you are protecting.

const key = 'login:' + (userId ?? clientIp);

The Fixed Window Algorithm

The simplest method counts requests per fixed time window. If the count exceeds the limit, reject until the window resets.

// allow 5 requests per 60 seconds
if (count > 5) return reject();

Counting in Redis

Redis is ideal: INCR bumps a counter atomically, and a TTL auto-expires the window. The first request sets the expiry.

const n = await redis.incr(key);
if (n === 1) await redis.expire(key, 60);
if (n > 5) throw new Error('Too many requests');

Sliding Window & Token Bucket

Fixed windows allow bursts at the edges. Sliding window smooths this, and token bucket permits short bursts while enforcing an average rate. Libraries like Upstash Ratelimit implement these for you.

import { Ratelimit } from '@upstash/ratelimit';
const rl = new Ratelimit({ redis, limiter: Ratelimit.slidingWindow(5, '60 s') });

Applying in Middleware

Centralize limiting in Next.js middleware so it runs before every matched request.

export async function middleware(req) {
  const { success } = await rl.limit(req.ip ?? 'anon');
  if (!success) return new Response('Rate limited', { status: 429 });
}

Returning 429 Properly

When limited, respond with status 429 and a Retry-After header telling clients when to try again.

return new Response('Too many requests', {
  status: 429,
  headers: { 'Retry-After': '60' }
});

Account Lockout

For login specifically, track failed attempts per account. After several failures, temporarily lock the account to stop targeted brute force.

const fails = await redis.incr('fail:' + email);
if (fails >= 5) await redis.expire('lock:' + email, 900);

Exponential Backoff

Increase the delay after each failure: 1s, 2s, 4s, 8s. This frustrates automated guessing while barely affecting legitimate users.

const delay = Math.min(2 ** fails, 60) * 1000;

Avoiding False Positives

Be careful not to punish real users:

  • Shared office IPs share a limit — prefer per-user keys when authenticated
  • Reset counters on success
  • Set generous limits for normal usage

Best Practices

Protect endpoints well:

  • Key limits on IP, user, or API key
  • Use Redis with sliding window or token bucket
  • Return 429 with Retry-After
  • Add lockout and backoff for login

Quick Check

Test your rate-limiting knowledge.

Recap

You learned to defend against abuse:

  • Key rate limits on IP, user, or API key
  • Count with Redis INCR and TTL, or use sliding window libraries
  • Return 429 with Retry-After
  • Add account lockout and exponential backoff for logins

Your auth and APIs now resist brute force and flooding.

Başlamak ücretsiz

Yapay zeka eğitmeniyle AI Powered SaaS: Stripe + Auth + Billing + Deploy öğren — ücretsiz

Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.

Kurslar
12
Dersler
48

Sıkça Sorulan Sorular

“İstek Hızı Sınırlama ve Kaba Kuvvet Saldırısı Koruması” dersi ücretsiz mi?

Evet — “İstek Hızı Sınırlama ve Kaba Kuvvet Saldırısı Koruması” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve AI Powered SaaS: Stripe + Auth + Billing + Deploy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. AI Powered SaaS: Stripe + Auth + Billing + Deploy kursu toplamda 4 dersten oluşur.

“İstek Hızı Sınırlama ve Kaba Kuvvet Saldırısı Koruması” dersinde ne öğreneceğim?

Redis gibi hızlı bir veri deposuyla istek hızı sınırlama, hesap kilitleme ve üstel geri çekilme kullanarak SaaS kimlik doğrulamanızı ve API'lerinizi kötüye kullanıma karşı koruyun. AI Powered SaaS: Stripe + Auth + Billing + Deploy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

AI Powered SaaS: Stripe + Auth + Billing + Deploy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te AI Powered SaaS: Stripe + Auth + Billing + Deploy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“İstek Hızı Sınırlama ve Kaba Kuvvet Saldırısı Koruması” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu AI Powered SaaS: Stripe + Auth + Billing + Deploy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her AI Powered SaaS: Stripe + Auth + Billing + Deploy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. OAuth 2.0 Entegrasyonu
  2. Çok Faktörlü Kimlik Doğrulama (MFA)
  3. Role Dayalı Erişim Denetimi (RBAC)
  4. İstek Hızı Sınırlama ve Kaba Kuvvet Saldırısı Koruması
← AI Powered SaaS: Stripe + Auth + Billing + Deploy Sayfasına Dön