Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAS 3.0 support #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

CAS 3.0 support #2

wants to merge 1 commit into from

Conversation

fmyzjs
Copy link

@fmyzjs fmyzjs commented Dec 3, 2014

CAS 3.0 support

To support CAS 3.0,the attribute mapper should be like:
@carsongee

def populate_user(user, authentication_response):
    if authentication_response is not None:
        if authentication_response.has_key('is_superuser'):
            user.is_superuser = authentication_response['is_superuser']

        if authentication_response.has_key('is_staff'):
            user.is_staff = authentication_response['is_staff']

        if authentication_response.has_key('givenName'):
            user.first_name = authentication_response['givenName']

        if authentication_response.has_key('sn'):
            user.last_name = authentication_response['sn']

        if authentication_response.has_key('email'):
            user.email = authentication_response['email']

    pass

CAS 3.0 support

To support CAS 3.0,the attribute mapper should be like:

```python

def populate_user(user, authentication_response):
    if authentication_response is not None:
        if authentication_response.has_key('is_superuser'):
            user.is_superuser = authentication_response['is_superuser']

        if authentication_response.has_key('is_staff'):
            user.is_staff = authentication_response['is_staff']

        if authentication_response.has_key('givenName'):
            user.first_name = authentication_response['givenName']

        if authentication_response.has_key('sn'):
            user.last_name = authentication_response['sn']

        if authentication_response.has_key('email'):
            user.email = authentication_response['email']

    pass
```
@carsongee
Copy link

Can you add a unit test for this? Also, do you know how you can determine if the response you get passed in is protocol version 2 or 3? Since they give very different attribute dictionaries, it would be nice to either add something to both of them, or at least know how to differentiate i.e.

if authentication_response is not None:
   if authentication_response.has_key('sn'):
       # Protocol 3.0 logic
   elif authentication_response.find(CAS + 'authenticationSuccess/'  + CAS + 'attributes'  , namespaces=NSMAP):
        # Protocol 2.0 attribute handler

@fmyzjs
Copy link
Author

fmyzjs commented Dec 3, 2014

What about this
set CAS_VERSION on aws.py

if CAS_VERSION=='3':
      pass

@carsongee
Copy link

Well, you won't necessarily know the version in the client at configuration time. i.e. I upgrade my CAS from Jasig 3.5 to 4.x then the attribute mapper would fail. In the worst case, I think my code example above would work as an example, and I could update our reference version to have that. The more I think about it, that is probably the only way to do it and maintain backwards compatibility with the current attribute mapper's out there.

@fmyzjs
Copy link
Author

fmyzjs commented Dec 4, 2014

.CAS_VERSION was 2 on init.py .if people try to use cas 3 ,must set var CAS_VERSION on configuration first.

@carsongee
Copy link

I totally missed that in init, and that it came from configuration already. Sorry about that. I just verified that there aren't issues with this in our current setup, so it looks good. I would just really like a unit test for it since I can't really verify myself without setting up a CAS 3.0 server. We will also need to have https://github.com/edx/edx-platform/pull/6127 merge before I merge this.

@pdpinch
Copy link
Member

pdpinch commented Aug 20, 2015

@carsongee what do you think we should do with this and mitocw/mitx_cas_mapper#1

@carsongee
Copy link

I think it would be nice if we wrote tests and validated that this works with a CAS 3.0 server as it would be valuable to the edx community. A better option may be switching the platform to using https://github.com/mingchen/django-cas-ng as it is a much better maintained fork, though they only test down to Django 1.5, so it may not work with our 1.4 installation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants