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

Commit

Permalink
backoffice: orcidlogin from frontend implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
drjova authored and DonHaul committed Sep 24, 2024
1 parent fd58651 commit 2b6263f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 126 deletions.
3 changes: 3 additions & 0 deletions backoffice/.envs/local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ AIRFLOW_BASE_URL=http://airflow-webserver:8080
AIRFLOW_TOKEN=YWlyZmxvdzphaXJmbG93

SERVICENOW_URL=https://cerntraining.service-now.com

# Frontend
FRONTEND_LOGIN_SUCCESS=http://127.0.0.1:5000/success
4 changes: 2 additions & 2 deletions backoffice/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
AUTH_USER_MODEL = "users.User"
# https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
LOGIN_REDIRECT_URL = "users:redirect"
LOGIN_REDIRECT_URL = env("FRONTEND_LOGIN_SUCCESS")
# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
LOGIN_URL = "account_login"

Expand Down Expand Up @@ -331,7 +331,7 @@
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_VERIFICATION = False
# https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_ADAPTER = "backoffice.users.adapters.AccountAdapter"
# https://django-allauth.readthedocs.io/en/latest/forms.html
Expand Down
4 changes: 4 additions & 0 deletions backoffice/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from allauth.socialaccount.providers.orcid.views import oauth2_login
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
Expand All @@ -8,6 +9,8 @@
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from rest_framework.authtoken.views import obtain_auth_token
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
from django.views.decorators.csrf import csrf_exempt


urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
Expand All @@ -18,6 +21,7 @@
path(settings.ADMIN_URL, admin.site.urls),
# User management
path("users/", include("backoffice.users.urls", namespace="users")),
path("accounts/orcid/login/", csrf_exempt(oauth2_login), name="orcid_login"),
path("accounts/", include("allauth.urls")),
path("", include("django_prometheus.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Expand Down
131 changes: 9 additions & 122 deletions backoffice/poetry.lock

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

2 changes: 1 addition & 1 deletion backoffice/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ uvicorn = {version = "0.23.2", extras = ["standard"]}
django = "4.2.6"
django-environ = "0.11.2"
django-model-utils = "4.3.1"
django-allauth = "0.57.0"
django-crispy-forms = "2.1"
crispy-bootstrap5 = "0.7"
django-redis = "5.4.0"
Expand All @@ -150,6 +149,7 @@ opensearch-py = "2.6.0"
djangorestframework-simplejwt = "^5.3.1"
django-json-widget = "^2.0.1"
sentry-sdk = "1.19.1"
django-allauth = {version = "65.0.1", extras = ["headless"]}

[tool.poetry.dev-dependencies]
factory-boy = "3.3.0"
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ services:
ports:
- "8000:8000"
command: sh -c 'poetry run python manage.py migrate && poetry run python manage.py opensearch index rebuild --force && poetry run python manage.py opensearch document index --force && poetry run python manage.py runserver 0.0.0.0:8000'
stdin_open: true
tty: true

postgres-airflow:
image: postgres:13
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target-version = "py311"
ignore = ["PT009"]
lint.ignore = ["PT009"]

[lint.flake8-tidy-imports]
ban-relative-imports = "all"
Expand Down

0 comments on commit 2b6263f

Please sign in to comment.