微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

极慢的 Oauth 身份验证 django-allauth

如何解决极慢的 Oauth 身份验证 django-allauth

当我尝试注册时: 保持电子邮件验证 =“强制”,

  • 通过 Github 加载回调 URL 大约需要 3-10 分钟。
  • 通过电子邮件/密码注册,在注册按钮“之后”加载 url 需要 3-10 分钟。

保持电子邮件验证=“无”,

  • 通过 Github 加载回调 URL 大约需要 3-10 分钟。
  • 通过电子邮件/密码注册正在顺利进行。

以下是代码文件

settings.py:

Django settings for config project.

Generated by 'django-admin startproject' using Django 3.2.

For more information on this file,see
https://docs.djangoproject.com/en/3.2/topics/settings/

For the full list of settings and their values,see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# Security WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-xc-592)no)((2&6grj56rfw$um58(cd(+0zvs2f=ar0wq6&@0='

# Security WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application deFinition

INSTALLED_APPS = [
    'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','django.contrib.sites',# new
    'userlogin','allauth',# new
    'allauth.account',# new
    'allauth.socialaccount',# new
    'allauth.socialaccount.providers.github',# new
    'allauth.socialaccount.providers.shopify',]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]

ROOT_URLconf = 'config.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates','Dirs': [os.path.join(BASE_DIR,'templates'),os.path.join(BASE_DIR,'templates','allauth')],'APP_Dirs': True,'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},]

Wsgi_APPLICATION = 'config.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3','NAME': BASE_DIR / 'db.sqlite3',}
}


# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',{
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',{
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',{
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS,JavaScript,Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend","allauth.account.auth_backends.AuthenticationBackend",)

SITE_ID = 1

ACCOUNT_EMAIL_VERIFICATION = 'none'

LOGIN_REDIRECT_URL = 'home'
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_required = True
ACCOUNT_EMAIL_VERIFICATION = 'none'
ACCOUNT_USERNAME_required = False

#mailgun creds
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_HOST_USER = 'postmaster1@alerts.xxxxxx.io'
EMAIL_HOST_PASSWORD = 'xxxxxxx'
EMAIL_PORT = 587
ACCOUNT_CONFIRM_EMAIL_ON_GET = True
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True

#Modifying shopify access scope

SOCIALACCOUNT_PROVIDERS = {
    'shopify': {
        'ScopE': ['read_products','write_products','read_orders','write_orders','write_order_edits']
    }
}

项目树:https://take.ms/6EZpg

urls.py:

from django.contrib import admin
from django.urls import path,include
from userlogin import views

urlpatterns = [
    path('admin/',admin.site.urls),path('accounts/',include('allauth.urls')),path('',views.home,name='home'),path('orders/',views.orders,name='orders'),]

控制台日志:

[16/May/2021 01:05:07] "GET /accounts/github/login/?process=login&next=%2F HTTP/1.1" 302 0
[16/May/2021 01:13:23] "GET /accounts/github/login/callback/?code=e4f316f33ab6aa66b058&state=MjOwL8N4N2bK HTTP/1.1" 302 0
[16/May/2021 01:13:23] "GET /accounts/confirm-email/ HTTP/1.1" 200 882

[16/May/2021 00:50:20] "GET /accounts/signup/?next=%2F HTTP/1.1" 200 1690
[16/May/2021 00:54:31] "POST /accounts/signup/ HTTP/1.1" 302 0
[16/May/2021 00:54:31] "GET /accounts/confirm-email/ HTTP/1.1" 200 882

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。