Attachment 'moin-1.5.8_http_and_cookie_auth.patch'

Download

   1 diff -Naur moin-1.5.8.orig/MoinMoin/action/http_login.py moin-1.5.8/MoinMoin/action/http_login.py
   2 --- moin-1.5.8.orig/MoinMoin/action/http_login.py	1970-01-01 01:00:00.000000000 +0100
   3 +++ moin-1.5.8/MoinMoin/action/http_login.py	2007-11-22 15:06:09.000000000 +0100
   4 @@ -0,0 +1,49 @@
   5 +# -*- coding: iso-8859-1 -*-
   6 +"""
   7 +    MoinMoin - "http_login" action
   8 +
   9 +    This action provides a redirection 
  10 +    to the HTTP authentication trigger
  11 +    (i.e. "<calling_page>/login?action=http_login")
  12 +    and a redirection back to the calling page
  13 +    after the HTTP authentication completed successfully
  14 +
  15 +    NB - the HTTP authentication trigger works only
  16 +    if you have your web server properly configured !!
  17 +
  18 +    i.e. for Apache:
  19 +
  20 +    <LocationMatch "/[^/]+/login">
  21 +        ....your auth method here...
  22 +        AuthType Basic | Digest
  23 +        ...etc...
  24 +    </LocationMatch>
  25 +
  26 +    @copyright: 2007 by Gianluca Cangini <gianluca.cangini@telecomitalia.it>
  27 +    @license: GNU GPL, see COPYING for details.
  28 +"""
  29 +
  30 +from MoinMoin import user
  31 +from MoinMoin.Page import Page
  32 +
  33 +def execute(pagename, request):
  34 +    return HttpLoginHandler(pagename, request).handle()
  35 +
  36 +class HttpLoginHandler:
  37 +    def __init__(self, pagename, request):
  38 +        self.request = request
  39 +        self._ = request.getText
  40 +        self.page = Page(request, pagename)
  41 +
  42 +    def handle(self):
  43 +        _ = self._
  44 +        request = self.request
  45 +
  46 +        if request.user.valid: 
  47 +            # user successfully authenticated via HTTP
  48 +            request.http_redirect(request.http_referer)
  49 +        
  50 +        else: 
  51 +            # force a redirect to the HTTP authentication trigger
  52 +            request.http_redirect(request.http_referer + "/login?action=http_login")
  53 +
  54 diff -Naur moin-1.5.8.orig/MoinMoin/auth.py moin-1.5.8/MoinMoin/auth.py
  55 --- moin-1.5.8.orig/MoinMoin/auth.py	2007-11-22 10:50:34.000000000 +0100
  56 +++ moin-1.5.8/MoinMoin/auth.py	2007-11-22 11:12:58.000000000 +0100
  57 @@ -132,6 +132,12 @@
  58      login = kw.get('login')
  59      logout = kw.get('logout')
  60      user_obj = kw.get('user_obj')
  61 +    
  62 +    # adds/refreshes cookie if a previous authentication method got a valid user
  63 +    if user_obj and user_obj.valid:
  64 +        setCookie(request, user_obj)
  65 +        return user_obj, True
  66 +
  67      #request.log("auth.moin_cookie: name=%s login=%r logout=%r user_obj=%r" % (username, login, logout, user_obj))
  68      if login:
  69          u = user.User(request, name=username, password=password,
  70 diff -Naur moin-1.5.8.orig/MoinMoin/multiconfig.py moin-1.5.8/MoinMoin/multiconfig.py
  71 --- moin-1.5.8.orig/MoinMoin/multiconfig.py	2007-11-22 10:50:34.000000000 +0100
  72 +++ moin-1.5.8/MoinMoin/multiconfig.py	2007-11-22 11:16:50.000000000 +0100
  73 @@ -342,6 +342,7 @@
  74      show_hosts = 1
  75      show_interwiki = 0
  76      show_login = 1
  77 +    login_action = 'login' # so the wiki adminstrator can set a different login action (e.g. 'http_login')
  78      show_names = True
  79      show_section_numbers = 0
  80      show_timings = 0
  81 diff -Naur moin-1.5.8.orig/MoinMoin/theme/__init__.py moin-1.5.8/MoinMoin/theme/__init__.py
  82 --- moin-1.5.8.orig/MoinMoin/theme/__init__.py	2007-11-22 10:50:34.000000000 +0100
  83 +++ moin-1.5.8/MoinMoin/theme/__init__.py	2007-11-22 11:18:16.000000000 +0100
  84 @@ -233,7 +233,7 @@
  85                                                     querystr={'action': 'logout', 'logout': 'logout'}, id="logout"))
  86              else:
  87                  userlinks.append(d['page'].link_to(request, text=_("Login", formatted=False),
  88 -                                                   querystr={'action': 'login'}, id="login"))
  89 +                                                   querystr={'action': request.cfg.login_action}, id="login"))
  90  
  91          userlinks = [u'<li>%s</li>' % link for link in userlinks]
  92          html = u'<ul id="username">%s</ul>' % ''.join(userlinks)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-11-22 15:37:37, 3.7 KB) [[attachment:moin-1.5.8_http_and_cookie_auth.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.