Using CAS and @auth.requires_login() decorator

23 views
Skip to first unread message

demetrio

unread,
Nov 8, 2010, 12:11:52 PM11/8/10
to web2py-users
Hi,

i'm trying to use CAS in my project, I can login and logout etc... but
if I use any decorator like @auth.requires_login() it shows the web2py
default login form.

There is any way to use the auth decorators with cas?

I've search in this group messages but i didn't find something useful
for my case.

Thx in advance

mdipierro

unread,
Nov 8, 2010, 12:47:01 PM11/8/10
to web2py-users
The CAS documentation is old.

You should use the CAS appliance for server but do not follow those
instructions for the clients. Instead follow the instructions in the
book (i.e. do not use cas.py).

Massimo

Daniel Gonzalez

unread,
Nov 8, 2010, 1:02:10 PM11/8/10
to web...@googlegroups.com
The online book says to use cas.py

http://web2py.com/book/default/chapter/08#Central-Authentication-Service

In the paper version of the book or in the pdf one, there is a different
documentation?

Daniel

mdipierro

unread,
Nov 8, 2010, 1:13:34 PM11/8/10
to web2py-users
You are right. The problem is the cas appliance had some problems to
begin with and has always been difficult to configure, because it
predates auth. What is in the book should work (using cas.py) but only
if you do not use Auth.

You may be better off using the cas consumer integrated in Auth:

gluon/contrib/login_methods/cas_auth.py

From the docstring in this file:

Login will be done via Web2py's CAS application, instead of
web2py's
login
form.

Include in your model (eg
db.py)::

from gluon.contrib.login_methods.cas_auth import
CasAuth

auth.define_tables(username=True)

auth.settings.login_form=CasAuth(

globals(),
urlbase = "https://web2py.com/cas/
cas",

actions=['login','check','logout'])

where urlbase is the actual CAS server url without the
login,logout...

Enjoy.

Daniel Gonzalez

unread,
Nov 8, 2010, 1:30:24 PM11/8/10
to web...@googlegroups.com
Ok, it works fine.

Thank you for everything Massimo

Reply all
Reply to author
Forward
0 new messages