from ipsilon.login.common import LoginPageBase, LoginManagerBase
from ipsilon.login.common import FACILITY
from ipsilon.util.plugin import PluginObject
+from ipsilon.util.user import UserSession
from string import Template
import cherrypy
import os
class KrbAuth(LoginPageBase):
def root(self, *args, **kwargs):
+ trans = self.get_valid_transaction('login', **kwargs)
# If we can get here, we must be authenticated and remote_user
# was set. Check the session has a user set already or error.
- if self.user and self.user.name:
+ us = UserSession()
+ us.remote_login()
+ self.user = us.get_user()
+ if not self.user.is_anonymous:
userdata = {'krb_principal_name': self.user.name}
- return self.lm.auth_successful(self.user.name, userdata)
+ return self.lm.auth_successful(trans, self.user.name,
+ 'krb', userdata)
else:
- return self.lm.auth_failed()
+ return self.lm.auth_failed(trans)
class KrbError(LoginPageBase):
# If we have no negotiate header return whatever mod_auth_kerb
# generated and wait for the next request
- if not 'WWW-Authenticate' in cherrypy.request.headers:
+ if 'WWW-Authenticate' not in cherrypy.request.headers:
cherrypy.response.status = 401
if self.lm.next_login:
cont=conturl)
# If we get here, negotiate failed
- return self.lm.auth_failed()
+ trans = self.get_valid_transaction('login', **kwargs)
+ return self.lm.auth_failed(trans)
class LoginManager(LoginManagerBase):
self.page = Krb(site, self)
self.page.__dict__['negotiate'] = KrbAuth(site, self)
self.page.__dict__['unauthorized'] = KrbError(site, self)
+ self.page.__dict__['failed'] = KrbError(site, self)
return self.page
Require valid-user
ErrorDocument 401 /${instance}/login/krb/unauthorized
+ ErrorDocument 500 /${instance}/login/krb/failed
</Location>
"""
order = []
order.insert(0, 'krb')
globalconf['order'] = ','.join(order)
- po.set_config(globalconf)
- po.save_plugin_config(FACILITY)
+ po.save_plugin_config(FACILITY, globalconf)