0Pricing
Spring Security 6 & JWT Authentication · Ders

JWT Süresinin Dolması ve Doğrulama Kuralları

JWT lifetime değerinin exp, nbf ve iat gibi zamana dayalı bildirimlerle nasıl denetlendiğini ve doğrulayıcıların süresi dolmuş veya zamanı henüz gelmemiş belirteçleri nasıl reddettiğini anlayın.

JWT Süresinin Dolması ve Doğrulama Kuralları, CoddyKit'te ücretsiz bir Spring Security 6 & JWT Authentication 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, Spring Security 6 & JWT Authentication öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Spring Security 6 & JWT Authentication kursu toplamda 4 dersten oluşur.

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

Why Tokens Need a Lifetime

A JWT is a bearer credential: whoever holds it is trusted. If a token never expired, a leaked token would grant access forever.

Time-based claims limit the damage window by making tokens valid only for a short period.

The exp Claim

The exp (expiration) claim is a Unix timestamp. After this moment the token is invalid and must be rejected.

{
  'sub': 'user123',
  'exp': 1717200000
}

The iat Claim

The iat (issued at) claim records when the token was created. It is useful for measuring token age and for revoking all tokens issued before a certain time.

{
  'sub': 'user123',
  'iat': 1717196400,
  'exp': 1717200000
}

The nbf Claim

The nbf (not before) claim defines the earliest time a token becomes valid. A token used before its nbf time must be rejected, which is handy for tokens scheduled to activate later.

{
  'sub': 'user123',
  'nbf': 1717196400,
  'exp': 1717200000
}

Choosing an Expiration Window

Short lifetimes are safer but force frequent re-authentication. A common pattern is:

  • Access token: 5-15 minutes
  • Refresh token: days or weeks

The short access token limits exposure; the refresh token keeps the user logged in.

Setting exp When Issuing

When you build a token, set exp relative to now. Here a 15-minute access token is created using a JWT library.

const now = Math.floor(Date.now() / 1000);
const payload = {
  sub: 'user123',
  iat: now,
  exp: now + 15 * 60
};

Validating exp on the Server

On every request the server checks exp against the current time. Most libraries do this automatically and throw if the token is expired.

try {
  const claims = verify(token, secret);
} catch (err) {
  if (err.name === 'TokenExpiredError') {
    // reject with 401
  }
}

Clock Skew

Servers do not always have perfectly synchronized clocks. A small leeway (a few seconds) prevents valid tokens from being rejected because of minor clock differences.

verify(token, secret, { clockTolerance: 5 });

exp Is Not Encryption

Remember: a JWT payload is only encoded, not encrypted. The exp claim stops the server from accepting the token, but anyone can read the claims. Never put secrets in the payload.

Reacting to Expiry on the Client

When the client gets a 401 due to expiry, it should silently request a new access token using the refresh token, then retry the original request.

if (response.status === 401) {
  const fresh = await refreshAccessToken();
  return retryWith(fresh);
}

Common Validation Mistakes

Watch out for these errors:

  • Forgetting to validate exp at all
  • Using milliseconds instead of seconds for the timestamp
  • Setting an excessively long lifetime
  • Ignoring nbf, allowing premature use

Quick Check

Test your knowledge of JWT time claims.

Recap

You learned how JWT lifetime is controlled:

  • exp sets the expiration; iat records issue time; nbf sets earliest validity
  • Use short access tokens plus longer refresh tokens
  • Allow small clock skew with leeway
  • exp does not encrypt the payload

Proper expiration handling keeps stolen tokens useful for only a brief window.

Sıkça Sorulan Sorular

“JWT Süresinin Dolması ve Doğrulama Kuralları” dersi ücretsiz mi?

Evet — “JWT Süresinin Dolması ve Doğrulama Kuralları” 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 Spring Security 6 & JWT Authentication kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Spring Security 6 & JWT Authentication kursu toplamda 4 dersten oluşur.

“JWT Süresinin Dolması ve Doğrulama Kuralları” dersinde ne öğreneceğim?

JWT lifetime değerinin exp, nbf ve iat gibi zamana dayalı bildirimlerle nasıl denetlendiğini ve doğrulayıcıların süresi dolmuş veya zamanı henüz gelmemiş belirteçleri nasıl reddettiğini anlayın. Spring Security 6 & JWT Authentication 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.

Spring Security 6 & JWT Authentication öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Spring Security 6 & JWT Authentication, 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.

“JWT Süresinin Dolması ve Doğrulama Kuralları” 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 Spring Security 6 & JWT Authentication dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Spring Security 6 & JWT Authentication 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. JSON Web Tokens'ı Anlama
  2. JWT Yapısı ve İddiaları
  3. JWT'leri İmzalama ve Doğrulama
  4. JWT Süresinin Dolması ve Doğrulama Kuralları
← Spring Security 6 & JWT Authentication Sayfasına Dön