Skip to content

CAS 3.0 support#2

Open
fmyzjs wants to merge 1 commit into
mitocw:masterfrom
fmyzjs:patch-1
Open

CAS 3.0 support#2
fmyzjs wants to merge 1 commit into
mitocw:masterfrom
fmyzjs:patch-1

Conversation

@fmyzjs
Copy link
Copy Markdown

@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
Copy Markdown

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
Copy Markdown
Author

fmyzjs commented Dec 3, 2014

What about this
set CAS_VERSION on aws.py

if CAS_VERSION=='3':
      pass

@carsongee
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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