Wiki source code of Authentication

Version 5.1 by rssh on 2008/02/11

Show last authors
1 1 User Authentication
2
3 XWiki supports several different authentication mechanisms for authenticating users:
4 #toc("" "" "")
5
6 The form authentication is the default mechanism.
7
8 #info("Note that currently XWiki allows only one method of authentication to be enabled at a time which means you cannot implement policies such as if the user is not found in LDAP then check if he's in the XWiki database. This will probably be improved in the future.")
9
10 1.1 Form Authentication
11
12 TODO
13
14 1.1 LDAP Authentication
15
16 1.1.1 Generic LDAP configuration
17
18 In order to enable the LDAP support you have to change the authentication method in ~~WEB-INF/xwiki.cfg~~ as follows:
19 {code}
20 xwiki.authentication.ldap=1
21 {code}
22
23 You can setup the LDAP configuration in the ~~xwiki.cfg~~ file by filling the following properties:
24 * xwiki.authentication.ldap.server
25 ** LDAP server, either an IP address or a host name. For example: localhost
26 * xwiki.authentication.ldap.port
27 ** LDAP server port number. Typical value is 389.
28 * xwiki.authentication.ldap.check_level
29 ** The default value is <tt>2</tt> if this property is not defined. Here are the possible values
30 *** checklevel 0: LDAP connection login to LDAP is sufficient
31 *** checklevel 1: Login & username located, attributes loaded
32 *** checklevel 2: Compare password for user (e.g. necessary if the LDAP bind didn't use the user's credentials)
33 * xwiki.authentication.ldap.base_DN
34 * xwiki.authentication.ldap.bind_DN
35 * xwiki.authentication.ldap.bind_pass
36 * xwiki.authentication.ldap.UID_attr
37 * xwiki.authentication.ldap.fields_mapping
38
39 Example:
40
41 {code}
42 xwiki.authentication.ldap=1
43 xwiki.authentication.ldap.authclass=com.xpn.xwiki.user.impl.LDAP.LDAPAuthServiceImpl
44 xwiki.authentication.ldap.server=dsmaster
45 xwiki.authentication.ldap.check_level=1
46 xwiki.authentication.ldap.port=389
47 xwiki.authentication.ldap.base_DN=department=USER,department=INFORMATIK,department=1230,o=MP
48 xwiki.authentication.ldap.bind_DN=cn={0},department=USER,department=INFORMATIK,department=1230,o=MP
49 xwiki.authentication.ldap.bind_pass={1}
50 xwiki.authentication.ldap.UID_attr=uid
51 {code}
52
53 #info("You can also setup the LDAP configuration in XWiki.XWikiPreferences page by going to the class editor and adding the following fields:
54 * ldap_server
55 * ldap_port
56 * ldap_check_level
57 * ldap_base_DN
58 * ldap_bind_DN
59 * ldap_bind_pass
60 * ldap_UID_attr
61 * ldap_fields_mapping")
62
63 1.1.1 LDAP Configuration for Active Directory
64
65 Here are values of the properties you need to set if your LDAP server implementation is Miscrosoft Active Directory:
66 - *ldap_server*: name/IP of AD server machine
67 - *ldap_port*: port ~~(e.g. 389)~~
68 - *ldap_check_level*: 1
69 - *ldap_base_DN*: name of root DN ~~(e.g. dc=ad,dc=company,dc=com)~~
70 - *ldap_bind_DN*: domain\{0\} ~~(e.g. ad\{0\} where \{0\} will be replaced by username during validation)~~
71 - *ldap_bind_pass*: \{1\} ~~(where \{1\} will be replaced by password during validation)~~
72 - *ldap_UID_attr*: sAMAccountName
73 - *ldap_fields_mapping*: name=sAMAccountName,last_name=sn,first_name=givenName,fullname=displayName,mail=mail,ldap_dn=dn
74
75 Example:
76 {code}
77 xwiki.authentication.ldap=1
78 xwiki.authentication.ldap.authclass=com.xpn.xwiki.user.impl.LDAP.LDAPAuthServiceImpl
79 xwiki.authentication.ldap.server=adserver
80 xwiki.authentication.ldap.check_level=1
81 xwiki.authentication.ldap.port=389
82 xwiki.authentication.ldap.base_DN=dc=subdomain,dc=domain,dc=suffix
83 xwiki.authentication.ldap.bind_DN=subdomain\\{0}
84 xwiki.authentication.ldap.bind_pass={1}
85 xwiki.authentication.ldap.UID_attr=sAMAccountName
86 xwiki.authentication.ldap.fields_mapping=name=sAMAccountName,last_name=sn,first_name=givenName,fullname=displayName,mail=mail,ldap_dn=dn
87 {code}
88
89 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.
90
91
92 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.
93
94 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.
95
96 This java client, [LDAP Browser/Editor > http://www-unix.mcs.anl.gov/~gawor/ldap/] is a handy tool for checking your configuration.
97
98
99
100
101 1.1 eXo Authentication
102
103 The eXo authentication is used automatically by adding/editing the ~~xwiki.exo=1~~ property in ~~WEB-INF/xwiki.cfg~~.
104
105 1.1 Custom Authentication
106
107 This allows plugging to any existing authentication mechanism such as SiteMinder, etc. To configure a custom authentication do the following:
108 # Implement the XWikiAuthService interface.
109 # Edit the ~~WEB-INF/xwiki.cfg~~ file and add a ~~xwiki.authentication.authclass~~ property pointing to your class. For example:
110
111 {code}
112 xwiki.authentication.authclass = com.acme.MyCustomAuthenticationService
113 {code}
114
115 Note, that you also can implement own right management service by implementing XWikiRightService interface:
116 {code}
117 xwiki.authentication.rightsclass = com.acme.MyCustomRightsService
118 {code}
119
120 and group service by implementing XWikiGroupService and setting ~~xwiki.authentication.groupclass~~ property.
121
122
123
124
125
126 1.1 Authentication parameters
127
128 You can set each of these parameters by setting:
129
130 {code}
131 xwiki.authentication.~~param_name~~=~~param_value~~
132 {code}
133
134 {table}
135 Name | Optional | Allowed values | Default value | Description
136 encryptionKey | No(1) | ? | n/a | Set 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.
137 validationKey | No(2) | ? | n/a | Set 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.
138 cookiedomains | Yes | String | Server host name | Which host(s) should your cookies be sent to; use only if you want to share cookies across domains, otherwise should be commented out
139 cookielife | Yes | Number | 14 | Number of days cookies take to expire
140 cookiepath | Yes | String | / | 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~~
141 default_page | Yes | String | /bin/view/ Main/WebHome | Page to redirect to if xredirect parameter is not set
142 encryptionalgorithm | Yes | ? | ? | Set the Encryption Algorithm used to encrypt and decrypt cookies
143 encryptionmode | Yes | ? | ? | Set the Encryption Mode used to encrypt and decrypt cookies
144 encryptionpadding | Yes | ? | ? | Set the Encryption Padding used to encrypt and decrypt cookies
145 errorpage | Yes | String | /bin/loginerror/ XWiki/XWikiLogin | Page to redirect to if there is an error logging in
146 loginpage | Yes | String | /bin/login/ XWiki/XWikiLogin | Page to redirect to when not logged in
147 loginsubmitpage | Yes | String | /loginsubmit/ XWiki/XWikiLogin | ?
148 logoutpage | Yes | String | /bin/logout/ XWiki/XWikiLogout | Page to redirect to after logged out
149 realname | Yes | String | XWiki | Sets the realm name (should be ~~realmname~~???)
150 protection | Yes | all, validation, encryption, none | all | Protection level for the "remember me" cookie functionality
151 unauthorized_code | Yes | ? | ? | ?
152 useip | Yes | true / false | true | Specify to use the IP address when encrypting the cookie data; if IP address changes will need to re-login.
153 {table}
154 # Only required if protection = encryption or all (default)
155 # Only required if protection = validation or all (default)

Get Connected