From 7ce5ebb4c3ced957c5c38413bfcfe5b166145640 Mon Sep 17 00:00:00 2001 From: Dmytro Nefyodov Date: Thu, 23 Jan 2025 12:14:12 +0200 Subject: [PATCH] feat: [PMA-98] add urls for Saml athentefication through mobile --- common/djangoapps/third_party_auth/urls.py | 18 +++++++++++++++++- openedx/core/djangoapps/oauth_dispatch/urls.py | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/common/djangoapps/third_party_auth/urls.py b/common/djangoapps/third_party_auth/urls.py index 6d600856f931..b93f2f342e9f 100644 --- a/common/djangoapps/third_party_auth/urls.py +++ b/common/djangoapps/third_party_auth/urls.py @@ -10,6 +10,12 @@ post_to_custom_auth_form, saml_metadata_view ) +from mobile_api_extensions.views import ( + auth_mobile, + complete_mobile, + redirect_to_mobile_deeplink, + redirect_to_mobile, +) urlpatterns = [ path('auth/inactive', inactive_user_view, name="third_party_inactive_redirect"), @@ -17,8 +23,18 @@ re_path(r'^auth/saml/metadata.xml', saml_metadata_view), re_path(r'^auth/login/(?Plti)/$', lti_login_and_complete_view), path('auth/idp_redirect/', IdPRedirectView.as_view(), name="idp_redirect"), - path('auth/', include('social_django.urls', namespace='social')), path('auth/saml/v0/', include('common.djangoapps.third_party_auth.samlproviderconfig.urls')), path('auth/saml/v0/', include('common.djangoapps.third_party_auth.samlproviderdata.urls')), path('auth/saml/v0/', include('common.djangoapps.third_party_auth.saml_configuration.urls')), ] + +urlpatterns += [ + re_path(r'^auth/login/(?P[^/]+)/$', auth_mobile, name='social_login_override'), + re_path(r'^auth/complete/(?P[^/]+)/$', + complete_mobile, + name='social_complete_override' + ), + path('auth/', include('social_django.urls', namespace='social')), + path('sso_deeplink', redirect_to_mobile_deeplink, name='sso-deeplink'), + re_path(r'^auth/login/mobile/(?P[^/]+)/$', redirect_to_mobile, name='redirect-mobile'), +] diff --git a/openedx/core/djangoapps/oauth_dispatch/urls.py b/openedx/core/djangoapps/oauth_dispatch/urls.py index 4d79ece81e59..b8bc93f3fbb4 100644 --- a/openedx/core/djangoapps/oauth_dispatch/urls.py +++ b/openedx/core/djangoapps/oauth_dispatch/urls.py @@ -7,6 +7,9 @@ from django.urls import path, re_path from django.views.decorators.csrf import csrf_exempt +from mobile_api_extensions.views import AuthorizationCodeExchangeView +from mobile_api_extensions.utils import is_enabled_mobile + from . import views urlpatterns = [ @@ -21,3 +24,12 @@ name='exchange_access_token', ), ] + +if is_enabled_mobile(): + urlpatterns.append( + re_path( + r'^exchange_authorization_code/?$', + csrf_exempt(AuthorizationCodeExchangeView.as_view()), + name='exchange_authorization_code', + ) + )