Commit 0822f33b authored by Gero Müller's avatar Gero Müller
Browse files

add remote login, e.g. apache ldap, over wsgi

parent 4a0ea14c
......@@ -87,3 +87,16 @@ smtp.port = 25
ignore = [dummy]
# Use REMOTE_USER variable for authentification
#remote.enabled = False
# Create non exisitng user after successful login
#remote.auto_create = True
# Use the email address from environment variable, e.g. HTTP_EMAIL
#remote.email_key = None
# Alternatively append the following domain as default, e.g.
#remote.email_domain = None
......@@ -138,6 +138,31 @@ class RootController(AbstractController):"sites/login.mako")
def login(self, *args, **kwargs):
path = self.requested_path()
db = cherrypy.request.db
login = cherrypy.request.login
if login and vispa.config("user", "remote.enabled", False):
user = User.get_by_name(db, login)
if user is None and vispa.config("user", "remote.auto_create", True):
email_key = vispa.config("user", "remote.email_key", None)
email_domain = vispa.config("user", "remote.email_domain", None)
if email_key:
email = cherrypy.request.wsgi_environ.get(email_key, None)
elif email_domain:
email = "%s@%s" % (login, email_domain)
user = User(name=login, password=User.generate_hash(64), email=email, hash=User.generate_hash(32), status=User.ACTIVE)
vispa.fire_callback("user.register", user)
vispa.fire_callback("user.activate", user)
cherrypy.session["user_id"] = unicode(
cherrypy.session["user_name"] =
vispa.fire_callback("user.login", user)
raise cherrypy.HTTPRedirect(path)
welcome_phrase = vispa.config("web", "text.welcome", "")
login_text = vispa.config("web", "text.login", "")
registration_text = vispa.config("web", "text.registration", "")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment