184 lines
4.4 KiB
Markdown
184 lines
4.4 KiB
Markdown
# 🚀 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
|
||
```bash
|
||
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):**
|
||
```bash
|
||
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ş):**
|
||
```bash
|
||
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:**
|
||
```bash
|
||
# Ö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)
|
||
```bash
|
||
# 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/` - Register
|
||
- `POST /api/v1/auth/users/activation/` - Activate account
|
||
- `POST /api/v1/auth/jwt/create/` - Login
|
||
- `POST /api/v1/auth/jwt/refresh/` - Refresh token
|
||
- `GET /api/v1/auth/users/me/` - Get profile
|
||
|
||
### Social Login
|
||
- `POST /api/v1/auth/social/google-oauth2/` - Google login
|
||
- `POST /api/v1/auth/social/github/` - GitHub login
|
||
- `POST /api/v1/auth/social/facebook/` - Facebook login
|
||
|
||
### Password Reset
|
||
- `POST /api/v1/auth/users/reset_password/` - Request reset
|
||
- `POST /api/v1/auth/users/reset_password_confirm/` - Confirm reset
|
||
|
||
## 📚 Detaylı Dokümantasyon
|
||
|
||
- **API Dokümantasyonu:** [AUTH.md](./AUTH.md)
|
||
- **Proje Genel Bakış:** [README.md](./README.md)
|
||
- **Geliştirme Notları:** [COPILOT_MEMORY.md](./COPILOT_MEMORY.md)
|
||
|
||
## 🛠️ Sonraki Adımlar
|
||
|
||
### 1. Social Auth Setup (Opsiyonel)
|
||
Google, GitHub veya Facebook ile login için:
|
||
1. Provider'dan OAuth credentials al
|
||
2. `.env` dosyasına ekle:
|
||
```bash
|
||
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](./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?
|
||
```bash
|
||
# 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ı
|
||
|
||
1. **Development:**
|
||
- `DEBUG=True` olmalı
|
||
- SQLite database kullan
|
||
- MailPit ile email test et
|
||
|
||
2. **Production:**
|
||
- `DEBUG=False` yap
|
||
- PostgreSQL kullan
|
||
- Gerçek SMTP provider kullan
|
||
- HTTPS enable et
|
||
|
||
3. **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](./AUTH.md) - Detaylı API dokümantasyonu
|
||
- [README.md](./README.md) - Proje genel bakış
|
||
- [COPILOT_MEMORY.md](./COPILOT_MEMORY.md) - Geliştirme notları
|
||
|
||
---
|
||
|
||
**Başarılar! 🎉**
|
||
|