From 8ce1621ec14728536758539b8465f4261466884e Mon Sep 17 00:00:00 2001 From: DonHaul Date: Mon, 5 Aug 2024 15:51:00 +0200 Subject: [PATCH] orcid-login: working locally --- backoffice/backoffice/workflows/providers.py | 6 ++++++ backoffice/config/api_router.py | 3 +++ backoffice/config/settings/base.py | 3 ++- backoffice/config/urls.py | 4 ++++ docker-compose.yaml | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 backoffice/backoffice/workflows/providers.py diff --git a/backoffice/backoffice/workflows/providers.py b/backoffice/backoffice/workflows/providers.py new file mode 100644 index 00000000..8ce81701 --- /dev/null +++ b/backoffice/backoffice/workflows/providers.py @@ -0,0 +1,6 @@ +from allauth.socialaccount.providers.orcid.provider import OrcidProvider + + +class CustomOrcidProvider(OrcidProvider): + def get_callback_url(self, request, app): + return "http://localhost:8000/api/api/oauth/authorized/orcid/" diff --git a/backoffice/config/api_router.py b/backoffice/config/api_router.py index 3969a7c2..41756453 100644 --- a/backoffice/config/api_router.py +++ b/backoffice/config/api_router.py @@ -13,6 +13,7 @@ router.register("users", UserViewSet) + # Workflows ( router.register( @@ -24,5 +25,7 @@ "workflow-update", WorkflowPartialUpdateViewSet, basename="workflow-update" ) (router.register("workflow-ticket", WorkflowTicketViewSet, basename="workflow-ticket"),) + + app_name = "api" urlpatterns = router.urls diff --git a/backoffice/config/settings/base.py b/backoffice/config/settings/base.py index e8fa6288..fd6d5758 100644 --- a/backoffice/config/settings/base.py +++ b/backoffice/config/settings/base.py @@ -379,7 +379,8 @@ "client_id": env("ORCID_CLIENT_ID", default=""), "secret": env("ORCID_CLIENT_SECRET", default=""), "key": "", - } + }, + "BASE_DOMAIN": "sandbox.orcid.org", } } diff --git a/backoffice/config/urls.py b/backoffice/config/urls.py index a35561e6..a30d6c16 100644 --- a/backoffice/config/urls.py +++ b/backoffice/config/urls.py @@ -1,3 +1,4 @@ +from allauth.socialaccount.providers.orcid.views import oauth2_callback from django.conf import settings from django.conf.urls.static import static from django.contrib import admin @@ -28,6 +29,9 @@ # API URLS urlpatterns += [ # API base url + path( + "api/oauth/authorized/orcid/", oauth2_callback, name="orcid_callback" + ), # Custom ORCID callback URL path("api/", include("config.search_router")), path("api/", include("config.api_router")), # DRF auth token diff --git a/docker-compose.yaml b/docker-compose.yaml index 96bd95cc..c8755fa3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -131,6 +131,8 @@ services: retries: 5 start_period: 5s restart: always + ports: + - "5432:5432" redis: image: redis:latest