Open chazzlabs opened 8 years ago
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.
As we intercept login view like this:
if view_func == login:
return cas_login(request, *view_args, **view_kwargs)
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?