HelpOnAuthentication

Not logged in - Log In / Register

How Authentication works with MoinMoin

MoinMoin has traditionally used cookie-based authentication: you log in via the form on page UserPreferences, then MoinMoin sets a cookie for authenticating you - until you log off which deletes the cookie (or until the cookie expires).

For running MoinMoin in a corporate environment this cookie-based system would prove unreliable and insecure. Therefore, MoinMoin can also use HTTP basic auth based authentication, when being run with web servers (e.g. Apache) that support it.

MoinMoin now has freely configurable modular authentication. Using the auth configuration value will set up a list of authentication methods that are processed in exactly that order.

When an external user database is used, you may not want to recreate all of the user accounts in MoinMoin. In this case the configuration option user_autocreate can be used. Setting it to True will allow a new user profile to be created automatically when a new user has passed authentication (and the auth method supports auto creation).

Presently the following authentication methods are supported:

Other "auth" methods

These are not strictly auth methods, as they don't authenticate users, but use auth information for other purposes:

Shipped plugins

moin_login and moin_session auth (default)

   1     from MoinMoin.auth import moin_login, moin_session
   2     auth = [moin_login, moin_session]

This is the default auth list moin uses (so if you just want that, you don't need to configure it).

moin_session should always be included since it manages the session cookie which is useful even if you don't authenticate using it since it manages session state. See HelpOnSessions for more information.

moin_anon_session

See HelpOnSessions.

http auth

To activate http authentication you have to add following lines to wikiconfig.py:

   1     from MoinMoin.auth.http import http
   2     from MoinMoin.auth import moin_session
   3     auth = [http, moin_session]

For HTTP basic auth used with a web server like Apache, the web server handles authentication before moin gets called. You either enter a valid username and password or your access will be denied by the web server.

So moin's http auth method will just check if user authentication happened:

Well, in reality, it is a bit more complicated indeed:

sslclientcert auth

To activate authentication via SSL client certificates you have to add following lines to wikiconfig.py:

   1     from MoinMoin.auth.sslclientcert import sslclientcert
   2     from MoinMoin.auth import moin_session
   3     auth = [sslclientcert, moin_session]

For SSL client certificate auth used with a web server like Apache, the web server handles authentication before moin gets called. You either have a valid SSL client certificate or your access will be denied by the web server.

So moin's sslclientcert auth method will just check if user authentication happened:

php_session

To activate Single-Sign-On integration with PHP applications, use this module. It reads PHP session files and therefore directly integrates with existing PHP authentication systems.

To use this module, use the following lines of code in your configuration:

   1     from MoinMoin.auth.php_session import php_session
   2     from MoinMoin.auth import moin_session
   3     auth = [php_session(), moin_session]

php_session has the following parameters:

   1 php_session(apps=['egw'], s_path="/tmp", s_prefix="sess_")

The only supported PHP application is eGroupware 1.2 currently. But it should be fairly easy to add a few lines of code that extract the necessary information from the PHP session.

Interwiki auth

Your moin 1.6 wiki can contact another moin 1.6 wiki to authenticate users (and transfer user profiles):

   1     from MoinMoin.auth.interwiki import interwiki
   2     from MoinMoin.auth import moin_session
   3     auth = [interwiki, moin_session]
   4     trusted_wikis = ['OtherWiki', ]

If you want to use this, you have to enter "OtherWiki UserName" into the login field (without the quotes), the password field gets the password for the user UserName on the wiki OtherWiki.

OtherWiki must be in your interwiki map, so moin can resolve it and it also must be a member of the trusted_wikis list in your wiki configuration.

LDAP auth

See /LDAP.

SMB pseudo-auth method

This method does not really do authentication, it just intercepts user/password from the auth chain to do its own stuff - mounting some smb share on login, umounting on logout:

    smb_server = "smb.example.org" # smb server name
    smb_domain = 'DOMAIN' # smb domain name
    smb_share = 'FILESHARE' # smb share we mount
    smb_mountpoint = u'/mnt/wiki/%(username)s' # where we mount the smb filesystem
    smb_display_prefix = u"S:" # where //server/share is usually mounted for your windows users (display purposes only)
    smb_dir_user = "wwwrun" # owner of the mounted directories
    smb_dir_mode = "0700" # mode of the mounted directories
    smb_file_mode = "0600" # mode of the mounted files
    smb_iocharset = "iso8859-1" # "UTF-8" > cannot access needed shared library!
    smb_coding = 'iso8859-1' # coding used for encoding the commandline for the mount command
    smb_verbose = True # if True, put SMB debug info into log
    smb_log = "/dev/null" # where we redirect mount command output to

This is for very special applications. If you don't know for what to use it, you probably don't need it.

wiki auth

This method was introduced with wikisync.

   1 import xmlrpclib
   2 
   3 name = "TestUser"
   4 password = "secret"
   5 wikiurl = "http://localhost:8080"
   6 
   7 homewiki = xmlrpclib.ServerProxy(wikiurl + "?action=xmlrpc2", allow_none=True)
   8 auth_token = homewiki.getAuthToken(name, password)
   9 
  10 mc = xmlrpclib.MultiCall(homewiki)
  11 mc.applyAuthToken(auth_token)
  12 result = mc()

Combining multiple auth methods

For combining e.g. http and cookie authentication, your wikiconfig.py might contain:

   1     from MoinMoin.auth import moin_login, moin_session
   2     from MoinMoin.auth.http import http
   3     auth = [http, moin_login, moin_session]

In this example, moin will first check if the http auth method gives a valid user. If yes, it will use just that. If not and continue_flag returned by http auth method is True, it will continue checking other auth list method - moin_login and moin_session in this case...

Making your own auth method

See the commented config file fragment contrib/auth_externalcookie/ and MoinMoin/auth/*.py in your moin distribution archive for examples of how to do authentication.

Here is just a short summary of what's currently possible: