Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
add social django
Browse files Browse the repository at this point in the history
  • Loading branch information
MJedr committed Nov 7, 2023
1 parent a64995c commit bb0530f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
12 changes: 10 additions & 2 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"corsheaders",
"drf_spectacular",
"oauth2_provider",
"social_django",
]

LOCAL_APPS = ["backoffice.users", "backoffice.workflows", "backoffice.management"]
Expand Down Expand Up @@ -201,6 +202,8 @@
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"backoffice.users.context_processors.allauth_settings",
"social_django.context_processors.backends",
"social_django.context_processors.login_redirect",
],
},
}
Expand Down Expand Up @@ -352,5 +355,10 @@
"VERSION": "1.0.0",
"SERVE_PERMISSIONS": ["rest_framework.permissions.IsAdminUser"],
}
# Your stuff...
# ------------------------------------------------------------------------------
# OAuth
SOCIAL_AUTH_JSONFIELD_ENABLED = True
SOCIAL_AUTH_AUTHENTICATION_BACKENDS = (
"social_core.backends.orcid.OrcidOAuth2",
"django.contrib.auth.backends.ModelBackend",
)
SOCIAL_AUTH_USER_MODEL = "users.User"
2 changes: 2 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from django.views.generic import TemplateView
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from rest_framework.authtoken.views import obtain_auth_token
from social_django.urls import urlpatterns as social_django_urls

urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
path("about/", TemplateView.as_view(template_name="pages/about.html"), name="about"),
# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL, admin.site.urls),
path("oauth2/", include("oauth2_provider.urls", namespace="oauth2_provider")),
path("auth/", include(social_django_urls, namespace="social")),
# User management
path("users/", include("backoffice.users.urls", namespace="users")),
path("accounts/", include("allauth.urls")),
Expand Down
43 changes: 42 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ django-anymail = "10.1"
dj-database-url = "^2.1.0"
django-oauth-toolkit = "2.3.0"
whitenoise = "^6.6.0"
social-auth-app-django = "^5.4.0"

[tool.poetry.dev-dependencies]
factory-boy = "3.3.0"
Expand Down

0 comments on commit bb0530f

Please sign in to comment.