jbittel/django-mama-cas

Single Sign Out

manelclos opened this issue · 6 comments

Hi,

I've been using django-mama-cas with the django_cas_ng client for some time now. I'm trying to use Single Sign Out, but it does not work because the client expects to receive the sign out request under the logoutRequest parameter, and django-mama-cas is not doing that.

Can you please see the reasoning in the django_cas_ng issue below and tell me if it is ok to modify django-mama-cas in this regard?

django-cas-ng/django-cas-ng#82

Thanks in advance!

Thanks for pointing this out! This ought to resolve the issue, although I don't have a chance to test it against a live client at the moment. If you're able to check it and verify that it works, it would be most appreciated.

Hi Jason,

I also tried that myself before trying to fix django_cas_ng. I think the problem is that because the body is in xml format (the headers set content_type: text/xml), the application running django_cas_ng will not see the parameter because django will not decode and put it in the POST dictionary, that's why I used request.body (https://docs.djangoproject.com/es/1.9/ref/request-response/#django.http.HttpRequest).

I'll test any solution, right now the production code is just bad patched.

Hi Jason,

Finally got it working just by modifying django-mama-cas:

  • remove text/xml header in models.py:268:
    resp = requests.post(self.service,
    data={'logoutRequest': request.render_content()})
  • remove utf-8 encoding in request.py:62:
    return etree.tostring(logout_request)

This was adding the encoding declaration: "" a producing this error on django_cas_ng:
Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

Do you thing these changes can go in?

Ah! I didn't think about that yesterday when I made that change. Yes, I'll make those changes as well.

Thanks!

I pushed up 1377158 which implements the changes you listed above. Please let me know if you continue to run into problems for some reason. Thanks for your help in reporting this and tracking down the solution!

Tested django-mama-cas git version against django-cas-ng==3.5.3, works perfect! Thanks a lot!