Files
shopback/QUICK_START.md
Beyhan Oğur d9f1ea341e first commit
2026-04-26 22:27:56 +03:00

4.4 KiB
Raw Permalink Blame History

🚀 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/ - 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

🛠️ 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:
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ı

  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:


Başarılar! 🎉