feat(config): add Google OAuth client configuration and extend external URL routes

Add GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REDIRECT_URI env vars and configure external access endpoints for OAuth callback and logout.
This commit is contained in:
sankalp committed 2026-06-25 23:29:46 +05:45
1 parent 9d11d397cb
commit a5ca9a8cd6
2 files changed
+262 -67

No files matched your search

+38 -17
View File
@@ -3,7 +3,6 @@ generated with djinit
Common settings shared between development and production environment
"""
import os
from datetime import timedelta
from pathlib import Path
@@ -24,11 +23,12 @@ BASE_DIR = Path(__file__).resolve().parent.parent.parent
THIRD_PARTY_APPS = [
"rest_framework",
"rest_framework_simplejwt",
"rest_framework_simplejwt.token_blacklist",
"corsheaders",
"drf_yasg",
"drf_spectacular",
"django_tailwind_cli",
"django_htmx",
"import_export",
"django_filters",
]
USER_DEFINED_APPS = [
@@ -71,13 +71,14 @@ ROOT_URLCONF = "config.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"src.config.context_processors.site_stats",
],
},
},
@@ -86,6 +87,8 @@ TEMPLATES = [
WSGI_APPLICATION = "config.wsgi.application"
AUTH_USER_MODEL = "accounts.User"
# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
@@ -104,12 +107,14 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/dashboard/"
# Internationalization
# https://docs.djangoproject.com/en/5.2/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
TIME_ZONE = "Asia/Kathmandu"
USE_I18N = True
USE_TZ = True
@@ -133,29 +138,45 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# REST Framework Settings
REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": [
"rest_framework.renderers.JSONRenderer",
],
"DEFAULT_PARSER_CLASSES": [
"rest_framework.parsers.JSONParser",
],
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
"rest_framework.authentication.SessionAuthentication",
),
"DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema",
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
"PAGE_SIZE": 20,
"PAGE_SIZE": 50,
"DEFAULT_FILTER_BACKENDS": (
"django_filters.rest_framework.DjangoFilterBackend",
"rest_framework.filters.SearchFilter",
"rest_framework.filters.OrderingFilter",
),
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
}
# JWT Settings
# SimpleJWT
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(days=1),
"REFRESH_TOKEN_LIFETIME": timedelta(days=3),
"ACCESS_TOKEN_LIFETIME": timedelta(hours=1),
"REFRESH_TOKEN_LIFETIME": timedelta(days=30),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True,
"AUTH_HEADER_TYPES": ("Bearer",),
}
# Google OAuth
GOOGLE_CLIENT_ID = env("GOOGLE_CLIENT_ID", default="")
GOOGLE_CLIENT_SECRET = env("GOOGLE_CLIENT_SECRET", default="")
GOOGLE_REDIRECT_URI = env(
"GOOGLE_REDIRECT_URI", default="http://localhost:8000/api/auth/google/callback/"
)
# Spectacular
SPECTACULAR_SETTINGS = {
"TITLE": "Project Management API",
"DESCRIPTION": "Django port of Project Management",
"VERSION": "1.0.0",
}
# CORS Settings
CORS_ALLOW_METHODS = [
"DELETE",