You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to add CAS authentication to an existing Django/DRF app using django-cas. I've been successful so far except for redirecting to the CAS login page via the "Login" link in the DRF API page. If I explicitly navigate to the CAS login page and again explicitly to the DRF API page I'm properly authenticated; it's just redirecting within the app that seems to be giving me a problem. This perhaps has more to do with my unfamiliarity with Django, but I'm hoping I might at least get some confirmation on my setup.
It seems my issue is that, since the app is using the default DRF rest_framework.urls login view, it's sending a template_name keyword arg to the login() function of django-cas, which doesn't support the argument. I've configured django-cas according to the README, setting CAS_SERVER_URL, adding cas.middleware.CASMiddleware, adding the CAS login/logout URLs, and adding the AUTHENTICATION_BACKENDS. I've also configured DRF to use rest_framework.authentication.SessionAuthentication.
Is it possible to have the default DRF login views redirect to CAS, or is there perhaps another way I should go about this?
The text was updated successfully, but these errors were encountered:
The DRF login URL config is just pointing to the built in django views and passing in a template specific to the DRF project. If you are using CAS you'd always want to use the CAS login/logout views in order for it to properly work. The other way it could be solved is to allow a template_name parameter, but that isn't really solving the problem.
Bottom line is that if you are going to use CAS, it's best to explicitly call the login/logout views in django-cas and not any others.
I think cas_login should be capable of handling all paramters django.contrib.auth.views accept, maybe just accept and ignore them, so no exception will be raised.
I‘m also wondering whether we should add a option to disable this kind of view intercept, so if our CAS server down, we can fallback to local login.
I'm attempting to add CAS authentication to an existing Django/DRF app using django-cas. I've been successful so far except for redirecting to the CAS login page via the "Login" link in the DRF API page. If I explicitly navigate to the CAS login page and again explicitly to the DRF API page I'm properly authenticated; it's just redirecting within the app that seems to be giving me a problem. This perhaps has more to do with my unfamiliarity with Django, but I'm hoping I might at least get some confirmation on my setup.
More specifically, I'm seeing this error:
It seems my issue is that, since the app is using the default DRF
rest_framework.urls
login view, it's sending atemplate_name
keyword arg to thelogin()
function of django-cas, which doesn't support the argument. I've configured django-cas according to the README, settingCAS_SERVER_URL
, addingcas.middleware.CASMiddleware
, adding the CAS login/logout URLs, and adding theAUTHENTICATION_BACKENDS
. I've also configured DRF to userest_framework.authentication.SessionAuthentication
.Is it possible to have the default DRF login views redirect to CAS, or is there perhaps another way I should go about this?
The text was updated successfully, but these errors were encountered: