4.4 KiB
4.4 KiB
🚀 Quick Start Guide
Django REST API Authentication sistemi başarıyla kuruldu! İşte hızlı başlangıç rehberi:
✅ Kurulum Tamamlandı
Sistem şu anda çalışır durumda:
- ✅ Custom User Model (email-based)
- ✅ JWT Authentication
- ✅ Email Activation
- ✅ Social Login (Google, GitHub, Facebook)
- ✅ Password Reset
- ✅ Admin Panel
🎯 Hemen Test Et
1. Server Çalıştır
cd /home/beyhan/Python/server
source .venv/bin/activate
python manage.py runserver
2. Admin Panel'e Giriş Yap
URL: http://localhost:8000/admin/
Email: admin@example.com
Password: admin123
3. API Test Et
Register (Kayıt):
curl -X POST http://localhost:8000/api/v1/auth/users/ \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "TestP@ss123",
"re_password": "TestP@ss123",
"first_name": "Test",
"last_name": "User"
}'
Login (Giriş):
curl -X POST http://localhost:8000/api/v1/auth/jwt/create/ \
-H "Content-Type: application/json" \
-d '{
"email": "admin@example.com",
"password": "admin123"
}'
Get User Profile:
# Önce login olup token al, sonra:
curl -X GET http://localhost:8000/api/v1/auth/users/me/ \
-H "Authorization: Bearer <your_access_token>"
📧 Email Testing
MailPit Kurulumu (Opsiyonel)
# Docker ile
docker run -d -p 1025:1025 -p 8025:8025 axllent/mailpit
# Sonra email'leri görüntüle:
# http://localhost:8025
Not: MailPit olmadan da sistem çalışır, sadece email'ler console'a yazılır.
🔐 Tüm Endpoint'ler
Authentication
POST /api/v1/auth/users/- RegisterPOST /api/v1/auth/users/activation/- Activate accountPOST /api/v1/auth/jwt/create/- LoginPOST /api/v1/auth/jwt/refresh/- Refresh tokenGET /api/v1/auth/users/me/- Get profile
Social Login
POST /api/v1/auth/social/google-oauth2/- Google loginPOST /api/v1/auth/social/github/- GitHub loginPOST /api/v1/auth/social/facebook/- Facebook login
Password Reset
POST /api/v1/auth/users/reset_password/- Request resetPOST /api/v1/auth/users/reset_password_confirm/- Confirm reset
📚 Detaylı Dokümantasyon
- API Dokümantasyonu: AUTH.md
- Proje Genel Bakış: README.md
- Geliştirme Notları: COPILOT_MEMORY.md
🛠️ Sonraki Adımlar
1. Social Auth Setup (Opsiyonel)
Google, GitHub veya Facebook ile login için:
- Provider'dan OAuth credentials al
.envdosyasına ekle:
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=your-client-id
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=your-client-secret
2. Frontend Entegrasyonu
- Nuxt.js veya Next.js ile entegre et
- AUTH.md dosyasında detaylı örnekler var
3. Production Deployment
- PostgreSQL database kur
- SMTP email provider ayarla
- Environment variables'ı production için güncelle
- HTTPS enable et
✨ Özellikler
- ✅ Email-based authentication (username yok)
- ✅ JWT tokens (60 min access, 7 days refresh)
- ✅ Email activation (register sonrası)
- ✅ Social login (Google, GitHub, Facebook)
- ✅ Password reset
- ✅ Rate limiting (100/hour anon, 1000/hour user)
- ✅ CORS support (SPA için)
- ✅ Modern email templates
- ✅ Admin panel
🐛 Sorun Giderme
Server çalışmıyor?
# Virtual environment aktif mi kontrol et
source .venv/bin/activate
# Migration'lar uygulandı mı?
python manage.py migrate
# Port 8000 kullanımda mı?
lsof -i :8000
Email gönderilmiyor?
- MailPit çalışıyor mu?
http://localhost:8025 - Console'da email içeriğini görebilirsin
JWT token çalışmıyor?
- Token'ın expire olmadığından emin ol (60 dakika)
- Header formatı:
Authorization: Bearer <token>
💡 İpuçları
-
Development:
DEBUG=Trueolmalı- SQLite database kullan
- MailPit ile email test et
-
Production:
DEBUG=Falseyap- PostgreSQL kullan
- Gerçek SMTP provider kullan
- HTTPS enable et
-
Frontend:
- JWT tokens'ı localStorage veya cookie'de sakla
- Refresh token ile otomatik yenileme yap
- 401 hatalarında login sayfasına yönlendir
📞 Yardım
Sorularınız için:
- AUTH.md - Detaylı API dokümantasyonu
- README.md - Proje genel bakış
- COPILOT_MEMORY.md - Geliştirme notları
Başarılar! 🎉