Passkeys WebAuthn กับ CDN Configuration —

Passkeys และ WebAuthn

Passkeys เป็นวิธี Login แบบ Passwordless ที่ใช้ Biometrics หรือ Device PIN แทน Password ทำงานบน WebAuthn Standard ใช้ Public Key Cryptography ปลอดภัยจาก Phishing, Credential Stuffing และ Brute Force
เนื้อหาเกี่ยวข้อง — ทำความเข้าใจ windows server 2022 คือ
CDN ช่วยเพิ่ม Performance สำหรับ Authentication Flow Cache Static Assets, Edge Functions สำหรับ Token Validation, WAF ป้องกัน Attacks, Rate Limiting ที่ Edge
เนื้อหาเกี่ยวข้อง — ทำความเข้าใจ seo website คือ — ข้อมูลครบถ้วน 2026

CDN Configuration
# === CDN Configuration สำหรับ Authentication ===
# 1. Cloudflare Configuration
# cloudflare-workers/auth-edge.js
#
# export default {
# async fetch(request, env) {
# const url = new URL(request.url);
#
# // Rate Limiting สำหรับ Auth Endpoints
# if (url.pathname.startsWith('/api/login') ||
# url.pathname.startsWith('/api/register')) {
# const ip = request.headers.get('CF-Connecting-IP');
# const key = `rate::`;
# const count = await env.RATE_LIMIT.get(key);
#
# if (count && parseInt(count) > 10) {
# return new Response('Too Many Requests', { status: 429 });
# }
#
# await env.RATE_LIMIT.put(key, (parseInt(count || 0) + 1).toString(),
# { expirationTtl: 60 });
# }
#
# // JWT Validation ที่ Edge
# if (url.pathname.startsWith('/api/protected')) {
# const token = request.headers.get('Authorization')?.split(' ')[1];
# if (!token) {
# return new Response('Unauthorized', { status: 401 });
# }
# // Validate JWT at edge
# }
#
# return fetch(request);
# }
# };
# 2. Nginx CDN Cache Configuration
# /etc/nginx/conf.d/auth-cdn.conf
# # Cache Static Assets
# location ~* \.(js|css|png|jpg|svg|woff2)$ {
# proxy_cache static_cache;
# proxy_cache_valid 200 1d;
# add_header X-Cache $upstream_cache_status;
# add_header Cache-Control "public, max-age=86400";
# }
#
# # No Cache สำหรับ Auth Endpoints
# location /api/login {
# proxy_pass http://auth-backend;
# proxy_no_cache 1;
# proxy_cache_bypass 1;
# add_header Cache-Control "no-store";
#
# # Rate Limiting
# limit_req zone=auth_limit burst=10 nodelay;
# }
#
# location /api/register {
# proxy_pass http://auth-backend;
# proxy_no_cache 1;
# add_header Cache-Control "no-store";
# limit_req zone=auth_limit burst=5 nodelay;
# }
#
# # Security Headers
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# add_header X-Content-Type-Options "nosniff" always;
# add_header X-Frame-Options "DENY" always;
# add_header Content-Security-Policy "default-src 'self'" always;
# 3. Rate Limit Zone
# limit_req_zone $binary_remote_addr zone=auth_limit:10m rate=5r/s;
echo "CDN Configuration:"
echo " Static Assets: Cache 1 day"
echo " Auth Endpoints: No cache, Rate limited"
echo " Edge: JWT validation, Rate limiting"
echo " Security: HSTS, CSP, X-Frame-Options"
Best Practices
- Resident Keys: ใช้ Resident Keys (Discoverable Credentials) สำหรับ Usernameless Login
- User Verification: ตั้ง User Verification เป็น Required เสมอ
- Challenge Expiry: ตั้ง Challenge ให้ Expire ใน 5 นาที เก็บใน Redis
- Sign Count: ตรวจสอบ Sign Count ป้องกัน Cloned Authenticators
- CDN No-cache Auth: ไม่ Cache Auth Endpoints ที่ CDN
- Rate Limiting: ตั้ง Rate Limit สำหรับ Login/Register ที่ CDN Edge
Passkeys คืออะไร
วิธี Login Passwordless ใช้ Biometrics ลายนิ้วมือ Face ID Device PIN แทน Password ทำงานบน WebAuthn ปลอดภัยกว่า Password ไม่ Phishing ไม่ Leak Cross-device iCloud Google Password Manager
แนะนำเพิ่มเติม — อ่านเพิ่มเติมที่ SiamCafeBook
เนื้อหาเกี่ยวข้อง — ดูเพิ่มเติมเรื่อง Zipkin Tracing IoT Gateway





