开发者

Why is my school's CAS server not redirecting to my site after authenticating?

I'm trying to make a website that only University of Waterloo students can开发者_StackOverflow社区 use. It uses CAS for authentication. I started using the django_cas package. Followed the steps pretty much dead on. Here are the things I tested for:

redirected to CAS login page - pass

verify user on the CAS server - pass

redirect back to website - fail

(UPDATE: adding code to clarify) SOLUTION:

It seems I had the CAS_SERVER_URL wrong. The protocol is https instead of http for my school's CAS server

cas_django needs little configuration:

## in settings.py
   CAS_SERVER_URL = 'http://cas-dev.uwaterloo.ca/cas/'
   LOGIN_URL = '/accounts/login/'
   MIDDLEWARE_CLASSES = (
       'django.middleware.common.CommonMiddleware',
       'django.contrib.sessions.middleware.SessionMiddleware',
       'django.middleware.csrf.CsrfViewMiddleware',
       'django.contrib.auth.middleware.AuthenticationMiddleware',
       'django.contrib.messages.middleware.MessageMiddleware',
       'django_cas.middleware.CASMiddleware',
   )

   AUTHENTICATION_BACKENDS = (
       'django.contrib.auth.backends.ModelBackend',
       'django_cas.backends.CASBackend',
   )

## in urls.py
   (r'^accounts/login/$', 'django_cas.views.login'),
   (r'^accounts/logout/$', 'django_cas.views.logout'),

## in views.py
@login_required
def sample(request):
    return render_to_response('sample.html')

I got a 404 instead:

The requested URL /cas/login/http://uwnetwork.shaon.ca/accounts/login/?next=%2Fsample%2F was not found on this server.

Anybody know why it would fail to redirect?


You didn't really provide enough information for someone to give you a meaningful answer.

Try the following:

  1. Make sure that you properly set CAS_SERVER_URL as per the django_cas documentation.
  2. Talk to your university to make sure that the CAS server is allowed to redirect to your application. Since some information about the user is passed to the application upon successful authentication, it's possible that the server is configured to only allow sites hosted inside the .uwaterloo.ca domain to authenticate users.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜