Skip to content

Commit

Permalink
Merge pull request web2py#1533 from gchiesa/casv3
Browse files Browse the repository at this point in the history
implemented base support for CASv3
  • Loading branch information
mdipierro authored Nov 21, 2016
2 parents c600854 + 2c70a85 commit 67945c2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gluon/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,12 @@ def authentication():
return self.cas_validate(version=2, proxy=False)
elif args(1) == self.settings.cas_actions['proxyvalidate']:
return self.cas_validate(version=2, proxy=True)
elif (args(1) == 'p3'
and args(2) == self.settings.cas_actions['servicevalidate']):
return self.cas_validate(version=3, proxy=False)
elif (args(1) == 'p3'
and args(2) == self.settings.cas_actions['proxyvalidate']):
return self.cas_validate(version=3, proxy=True)
elif args(1) == self.settings.cas_actions['logout']:
return self.logout(next=request.vars.service or DEFAULT)
else:
Expand Down Expand Up @@ -2830,6 +2836,15 @@ def build_response(body):
if success:
if version == 1:
message = 'yes\n%s' % user[userfield]
elif version == 3:
username = user.get('username', user[userfield])
message = build_response(
TAG['cas:authenticationSuccess'](
TAG['cas:user'](username),
TAG['cas:attributes'](
*[TAG['cas:' + field.name](user[field.name])
for field in self.table_user()
if field.readable])))
else: # assume version 2
username = user.get('username', user[userfield])
message = build_response(
Expand Down Expand Up @@ -7072,4 +7087,4 @@ def save(self, options):

if __name__ == '__main__':
import doctest
doctest.testmod()
doctest.testmod()

0 comments on commit 67945c2

Please sign in to comment.