Integration with Jasig CAS

95 views
Skip to first unread message

Tanu Mittal

unread,
Aug 11, 2014, 7:59:33 AM8/11/14
to web...@googlegroups.com
Is It possible to integrate web2py with Jasig CAS ? Also which other python frameworks like Django, Flask can be integrated with Jasig CAS?

Massimo Di Pierro

unread,
Aug 11, 2014, 3:37:23 PM8/11/14
to web...@googlegroups.com
web2py has CAS support built-in. This means it should work with Jasig CAS as a client/consumer. You may need to configure it. It is explained in the manual but feel free to come back with questions.

Also notice web2py has a built-in CAS provider and it can replace Jasig CAS too.

I do not know if Django or Flask have anything equivalent.

Yusuf Kaka

unread,
Mar 2, 2015, 12:56:34 PM3/2/15
to web...@googlegroups.com
I've managed to get web2py to sign-on with JASIG CAS, however, none of the attributes are being populated on web2py. All user fields in the DB are set to None.

Any ideas?

Massimo Di Pierro

unread,
Mar 3, 2015, 11:54:47 AM3/3/15
to web...@googlegroups.com

From web2py/gluon/contrib/login_methods/cas_auth.py

    if you want to connect to a CAS version 2 JASIG Server use this:                                    
        auth.settings.login_form=CasAuth(                                                               
            urlbase = "https://[Your CAS server]/cas",                                                  
            actions = ['login','serviceValidate','logout'],                                             
            casversion = 2,                                                                             
            casusername = "cas:user")  

If you look in that file in CasAuth.__init__:

    def __init__(self, g=None,  # g for backward compatibility ###                                      
                 urlbase="https://web2py.com/cas/cas",
                 actions=['login', 'validate', 'logout'],
                 maps=dict(username=lambda v: v.get('username', v['user']),
                           email=lambda v: v.get('email', None),
                           user_id=lambda v: v['user']),
                 casversion=1,
                 casusername='cas:user'
                 ):

The maps argument is what you want. It maps fields from the JASIG response into fields in your auth_user table. CAS does not specify their names. Doh!
Reply all
Reply to author
Forward
0 new messages