ਆਧੁਨਿਕ ਐਪਲੀਕੇਸ਼ਨਾਂ ਵਿਭਿੰਨ ਪ੍ਰਮਾਣੀਕਰਣ ਵਿਧੀਆਂ ਦੀ ਵਰਤੋਂ ਕਰਦੀਆਂ ਹਨ — session-based, token-based (JWT), ਅਤੇ delegated authentication (OAuth/OpenID Connect)। ਹਰੇਕ ਕਿਵੇਂ ਕੰਮ ਕਰਦਾ ਹੈ ਇਹ ਸਮਝਣਾ, ਅਤੇ ਉਹਨਾਂ ਦੇ trade-offs, ਸੁਰੱਖਿਅਤ ਪ੍ਰਮਾਣੀਕਰਣ ਲਾਗੂ ਕਰਨ ਲਈ ਮਹੱਤਵਪੂਰਨ ਹੈ।
Session-based ਪ੍ਰਮਾਣੀਕਰਣ
SESSION-based (traditional):
→ user logs in → server creates a SESSION (stored server-side) → sends a session ID
cookie → the browser sends it with each request → server looks up the session
✓ server controls sessions (easy to revoke); simple; cookie auto-sent
✗ stateful (server stores sessions); scaling needs shared session storage
Token-based (JWT)
JWT (JSON Web Token):
→ user logs in → server issues a SIGNED token containing claims (user id, etc.) →
client stores it → sends it (usually in an Authorization header) per request →
server VERIFIES the SIGNATURE (no server-side lookup needed)
✓ STATELESS (scales easily; no session store); works well for APIs/SPAs/mobile
✗ hard to REVOKE before expiry (it's self-contained) → use short expiry + refresh tokens
⚠️ store securely; don't put secrets in the (readable) payload; validate properly
