User Authentication

XWiki supports several different authentication mechanisms for authenticating users:

The form authentication is the default mechanism.

Note that currently XWiki allows only one method of authentication to be enabled at a time which. This will probably be improved in the future.

Form Authentication

TODO

LDAP Authentication

Warning: New experimental service since XWiki Platform 1.3M2, see previous LDAP authentication service documentation

Generic LDAP configuration

In order to enable the LDAP support you have to change the authentication method in WEB-INF/xwiki.cfg as follows:

## Turn LDAP authentication on - otherwise only XWiki authentication
## 0 : disable
## 1 : enable
xwiki.authentication.ldap=1

## set LDAP as authentication service
xwiki.authentication.ldap.authclass=com.xpn.xwiki.user.impl.LDAP.XWikiLDAPAuthServiceImpl

You can setup the LDAP configuration in the xwiki.cfg file by filling the following properties:

## LDAP Server (Active Directory, eDirectory, OpenLDAP, etc.)
xwiki.authentication.ldap.server=156.58.101.204
xwiki.authentication.ldap.port=389

## LDAP login, empty = anonymous access, otherwise specify full dn 
## {0} is replaced with the username, {1} with the password
xwiki.authentication.ldap.bind_DN=cn={0},department=USER,department=INFORMATIK,department=1230,o=MP
xwiki.authentication.ldap.bind_pass={1}

#-# Force to check password after LDAP connection
#-# 0: disable
#-# 1: enable
xwiki.authentication.ldap.validate_password=0

## only members of the following group will be verified in the LDAP
## otherwise only users that are found after searching starting from the base_DN
xwiki.authentication.ldap.user_group=cn=developers,ou=groups,o=MegaNova,c=US

## base DN for searches
xwiki.authentication.ldap.base_DN=
department=USER,department=INFORMATIK,department=1230,o=MP

## specifies the LDAP attribute containing the identifier to be used as the XWiki name (default=cn)
xwiki.authentication.ldap.UID_attr=cn

## retrieve the following fields from LDAP and store them in the XWiki user object (xwiki-attribute=ldap-attribute)
xwiki.authentication.ldap.fields_mapping=last_name=sn,first_name=givenName,fullname=fullName,email=mail,ldap_dn=dn

# on every login update the mapped attributes from LDAP to XWiki otherwise this happens only once when the XWiki account is created.
xwiki.authentication.ldap.update_user=1

## maps XWiki groups to LDAP groups, separator is "|"
xwiki.authentication.ldap.group_mapping=XWiki.XWikiAdminGroup=cn=AdminRole,ou=groups,o=MegaNova,c=US|\
                                        XWiki.Organisation=cn=testers,ou=groups,o=MegaNova,c=US

## time in seconds after which the list of members in a group is refreshed from LDAP (default=3600*6)
xwiki.authentication.ldap.groupcache_expiration=21800

## - create : synchronize group membership only when the user is first created
## - always: synchronize on every login
xwiki.authentication.ldap.mode_group_sync=always

## if ldap authentication fails for any reason, try XWiki DB authentication with the same credentials
xwiki.authentication.ldap.trylocal=1

## SSL connection to LDAP server
## 0 : normal
## 1 : SSL
xwiki.authentication.ldap.ssl=1

## The keystore file to use in SSL connection
xwiki.authentication.ldap.ssl.keystore=

You can also setup the LDAP configuration in XWiki.XWikiPreferences page by going to the object editor

LDAP Configuration for Active Directory

Here are values of the properties you need to set if your LDAP server implementation is Miscrosoft Active Directory:

  • ldap_server: name/IP of AD server machine
  • ldap_port: port (e.g. 389)
  • ldap_base_DN: name of root DN (e.g. dc=ad,dc=company,dc=com)
  • ldap_bind_DN: domain{0} (e.g. ad{0} where {0} will be replaced by username during validation)
  • ldap_bind_pass: {1} (where {1} will be replaced by password during validation)
  • ldap_UID_attr: sAMAccountName
  • ldap_fields_mapping: name=sAMAccountName,last_name=sn,first_name=givenName,fullname=displayName,mail=mail,ldap_dn=dn
Example:
xwiki.authentication.ldap=1
xwiki.authentication.ldap.authclass=com.xpn.xwiki.user.impl.LDAP.XWikiLDAPAuthServiceImpl
xwiki.authentication.ldap.server=adserver
xwiki.authentication.ldap.port=389
xwiki.authentication.ldap.base_DN=dc=subdomain,dc=domain,dc=suffix
xwiki.authentication.ldap.bind_DN=subdomain\\{0}
xwiki.authentication.ldap.bind_pass={1}
xwiki.authentication.ldap.UID_attr=sAMAccountName
xwiki.authentication.ldap.fields_mapping=name=sAMAccountName,last_name=sn,first_name=givenName,fullname=displayName,mail=mail,ldap_dn=dn

The bind_DN and bind_pass fields contain the username and password for binding to the LDAP server in order to search, which will not necessarily be the same credentials as the user logging in.

The exact details of this configuration will vary based on your server configuration. It may not be necessary to prefix the username (represented by {0}) with the subdomain.

For testing purposes, you may wish to omit the "ldap.fields_mapping" field, to test the authentication first, and then add it later to get the mappings right.

This java client, LDAP Browser/Editor is a handy tool for checking your configuration.

eXo Authentication

The eXo authentication is used automatically by adding/editing the xwiki.exo=1 property in WEB-INF/xwiki.cfg.

Custom Authentication

This allows plugging to any existing authentication mechanism such as SiteMinder, etc. To configure a custom authentication do the following:

  1. Implement the XWikiAuthService interface.
  2. Edit the WEB-INF/xwiki.cfg file and add a xwiki.authentication.authclass property pointing to your class. For example:
xwiki.authentication.authclass = com.acme.MyCustomAuthenticationService

Note, that you also can implement own right management service by implementing XWikiRightService interface:

xwiki.authentication.rightsclass = com.acme.MyCustomRightsService

and group service by implementing XWikiGroupService and setting xwiki.authentication.groupclass property.

Authentication parameters

You can set each of these parameters by setting:

xwiki.authentication.~~param_name~~=~~param_value~~

NameOptionalAllowed valuesDefault valueDescription
encryptionKeyNo(1)?n/aSet the Encryption Key used to create a secret key, the secret key is passed to the Cipher object to be used during encryption and decryption of cookie values.
validationKeyNo(2)?n/aSet the Validation Key used to generate hash value; the hash value is stored with the cookie and used to verify that the cookie has not been tampered with.
cookiedomainsYesStringServer host nameWhich host(s) should your cookies be sent to; use only if you want to share cookies across domains, otherwise should be commented out
cookielifeYesNumber14Number of days cookies take to expire
cookiepathYesString/The webapp path that XWiki cookies should be sent to; if you have anything else running on your web server, this should be set to /xwiki
default_pageYesString/bin/view/ Main/WebHomePage to redirect to if xredirect parameter is not set
encryptionalgorithmYes??Set the Encryption Algorithm used to encrypt and decrypt cookies
encryptionmodeYes??Set the Encryption Mode used to encrypt and decrypt cookies
encryptionpaddingYes??Set the Encryption Padding used to encrypt and decrypt cookies
errorpageYesString/bin/loginerror/ XWiki/XWikiLoginPage to redirect to if there is an error logging in
loginpageYesString/bin/login/ XWiki/XWikiLoginPage to redirect to when not logged in
loginsubmitpageYesString/loginsubmit/ XWiki/XWikiLogin?
logoutpageYesString/bin/logout/ XWiki/XWikiLogoutPage to redirect to after logged out
realmnameYesStringXWikiSets the realm name
protectionYesall, validation, encryption, noneallProtection level for the "remember me" cookie functionality
unauthorized_codeYes???
useipYestrue / falsetrueSpecify to use the IP address when encrypting the cookie data; if IP address changes will need to re-login.
  1. Only required if protection = encryption or all (default)
  2. Only required if protection = validation or all (default)
Version 17.1 last modified by ThomasMortagne on 13/05/2008 at 12:14

Comments 7

xko | 02.04.2007 at 04:52 PM
Can anyone explain, how to build user's wikiname from LDAP fields? I suppose ldap_UID_attr or ldap_fields_mapping should do the job.

I managed to login with AD credentials, and now I have DENHOLM_INDUSTRIES
morism in the upper-right conner, but I beleive it should be MorisMoss.


BSayatovic | 09.05.2007 at 03:38 PM
I had a similar experience. I configured the LDAP authentication to go against Active Directory. While the authentication uses Active Directory, all of the other data that XWiki uses doesn't leverage the values from Active Directory. For example, the name displayed in the top-right corner is that from the XWiki user account, not the displayName from activeDirectory.

BSayatovic | 09.05.2007 at 03:39 PM
I had hoped setting up XWiki 1.0RC3 with LDAP/ActiveDirectory authentication meant that users present in my directory would automatically be able to log into XWiki; however, this is not the case. Users from LDAP/AD can't log in until I first register reate an XWiki User for them under the same name.

BSayatovic | 09.05.2007 at 03:39 PM
I had hoped setting up XWiki 1.0RC3 with LDAP/ActiveDirectory authentication meant that users present in my directory would automatically be able to log into XWiki; however, this is not the case. Users from LDAP/AD can't log in until I first register reate an XWiki User for them under the same name.

mamoulian | 09.08.2007 at 05:29 PM
Is the example AD configuration above the right way to do things? My understanding is that the bind_DN and bind_pass are for setting the username and password XWiki will use to connect to the LDAP server in order to do a search, then the UID_attr field is searched for the username entered on the form. If that is correct then the bind_dn and bind_pass should either be hardcoded to a special AD user with restricted privileges, or left blank to bind anonymously. I have tried the first of these: XWiki then seems to 'authenticate OK' whatever username/password I enter on the form even if the user does not exist in AD at all.

yjanet | 05.10.2007 at 12:03 PM
I need to use Sun Access Manager to authenticate users against global web SSO. I'm trying to build a new authentication module, but I can't find XWikiAuthService Javadoc … Isn't this public or should i retrieve whole sources and build the doc by myself ?

muxa | 07.11.2007 at 02:35 PM
I can login using AD credentials, but the only thing I see in my xWiki is an error: "You are not allowed to view this page..." I can't register the LDAP user in xWiki too, because in our AD our login format is name.surname!

Attachments 0

No attachments for this document

Creator: VincentMassol on 2007/03/24 21:18
This wiki is licensed under a Creative Commons license
1.3.2.9174