Add social auth Github + login page

This commit is contained in:
2024-10-05 14:16:08 +02:00
parent d7f0d2a7f2
commit 63897fb7b0
14 changed files with 210 additions and 55 deletions
+22 -21
View File
@@ -20,20 +20,13 @@ import os
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
SECRET_KEY = "django-insecure-changeme"
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-$440wv7cqb$-umfo-x%w_@p3g5kuuk1(!rv#=7*gzndx4_h4ds"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
@@ -43,6 +36,7 @@ INSTALLED_APPS = [
"django.contrib.staticfiles",
"django_js_reverse",
"djangobower",
"social_django",
"main",
"users",
"items",
@@ -50,13 +44,14 @@ INSTALLED_APPS = [
STATIC_URL = "/static/"
LOGIN_URL = "/"
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static_source"),)
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"djangobower.finders.BowerFinder",
# "compressor.finders.CompressorFinder",
)
STATIC_ROOT = os.path.join(BASE_DIR, "static")
@@ -64,7 +59,6 @@ STATIC_ROOT = os.path.join(BASE_DIR, "static")
STORAGES = {
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
# "BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
}
}
@@ -121,15 +115,8 @@ TEMPLATES = [
WSGI_APPLICATION = "app.wsgi.application"
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {}
# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
@@ -146,9 +133,6 @@ AUTH_PASSWORD_VALIDATORS = [
]
# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
@@ -160,6 +144,23 @@ USE_TZ = True
SIMPLE_HISTORY_HISTORY_ID_USE_UUID = True
SOCIAL_AUTH_JSONFIELD_ENABLED = True
AUTHENTICATION_BACKENDS = (
# "social_core.backends.open_id.OpenIdAuth",
# "social_core.backends.google.GoogleOpenId",
# "social_core.backends.google.GoogleOAuth2",
# "social_core.backends.google.GoogleOAuth",
# "social_core.backends.twitter.TwitterOAuth",
"social_core.backends.github.GithubOAuth2",
# "social_core.backends.yahoo.YahooOpenId",
# "django.contrib.auth.backends.ModelBackend",
)
SOCIAL_AUTH_GITHUB_KEY = ""
SOCIAL_AUTH_GITHUB_SECRET = ""
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
SOCIAL_AUTH_LOGIN_REDIRECT_URL = "/"
from app.settingsLocal import *
+5 -1
View File
@@ -14,8 +14,11 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from django_js_reverse.views import urls_js
@@ -24,5 +27,6 @@ urlpatterns = [
path("items/", include("items.urls")),
path("users/", include("users.urls")),
path("admin/", admin.site.urls),
path('reverse.js', urls_js, name='reverse_js'),
path("social/", include("social_django.urls", namespace="social")),
path("reverse.js", urls_js, name="reverse_js"),
]