You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup_authentication.mkd 7.5KB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ## Built-in Authentication
  2. By default, Gitblit stores and authenticates all users against `users.conf`. However, you may wish to integrate Gitblit into an existing user account infrastructure.
  3. Gitblit supports additional authentication mechanisms aside from it's internal one.
  4. * LDAP authentication
  5. * Windows authentication
  6. * Redmine auhentication
  7. * Salesforce.com authentication
  8. * Servlet container authentication
  9. ### LDAP Authentication
  10. *SINCE 1.0.0*
  11. LDAP can be used to authenticate Users and optionally control Team memberships. When properly configured, Gitblit will delegate authentication to your LDAP server and will cache some user information in the usual users file (.conf or .properties).
  12. When using the LDAP User Service, new user accounts can not be manually created from Gitblit. Gitblit user accounts are automatically created for new users on their first succesful authentication through Gitblit against the LDAP server. It is also important to note that the LDAP User Service does not retrieve or store user passwords nor does it implement any LDAP-write functionality.
  13. To use the *LdapUserService* set *realm.userService=com.gitblit.LdapUserService* in your `gitblit.properties` file or your `web.xml` file and then configure the *realm.ldap* settings appropriately for your LDAP environment.
  14. #### Example LDAP Layout
  15. ![block diagram](ldapSample.png "LDAP Sample")
  16. Please see [ldapUserServiceSampleData.ldif](https://github.com/gitblit/gitblit/blob/master/tests/com/gitblit/tests/resources/ldapUserServiceSampleData.ldif) to see the data in LDAP that reflects the above picture.
  17. #### Gitblit Settings for Example LDAP Layout
  18. The following are the settings required to configure Gitblit to authenticate against the example LDAP server with LDAP-controlled team memberships.
  19. <table class="table">
  20. <thead>
  21. <tr><th>parameter</th><th>value</th><th>description</th></tr>
  22. </thead>
  23. <tbody>
  24. <tr>
  25. <th>realm.ldap.server</th><td>ldap://localhost:389</td>
  26. <td>Tells Gitblit to connect to the LDAP server on localhost port 389. The URL Must be of form ldap(s)://&lt;server&gt;:&lt;port&gt; with port being optional (389 for ldap, 636 for ldaps).</td>
  27. </tr>
  28. <tr>
  29. <th>realm.ldap.username</th><td>cn=Directory Manager</td>
  30. <td>The credentials that will log into the LDAP server</td>
  31. </tr>
  32. <tr>
  33. <th>realm.ldap.password</th><td>password</td>
  34. <td>The credentials that will log into the LDAP server</td>
  35. </tr>
  36. <tr>
  37. <th>realm.ldap.backingUserService</th><td>users.conf</td>
  38. <td>Where to store all information that is used by Gitblit. All information will be synced here upon user login.</td>
  39. </tr>
  40. <tr>
  41. <th>realm.ldap.maintainTeams</th><td>true</td>
  42. <td>Are team memberships maintained in LDAP (<em>true</em>) or manually in Gitblit (<em>false</em>).</td>
  43. </tr>
  44. <tr>
  45. <th>realm.ldap.accountBase</th><td>OU=Users,OU=UserControl,OU=MyOrganization,DC=MyDomain</td>
  46. <td>What is the root node for all users in this LDAP system. Subtree searches will start from this node.</td>
  47. </tr>
  48. <tr>
  49. <th>realm.ldap.accountPattern</th><td>(&(objectClass=person)(sAMAccountName=${username}))</td><td>The LDAP search filter that will match a particular user in LDAP. ${username} will be replaced with whatever the user enters as their username in the Gitblit login panel.</td>
  50. </tr>
  51. <tr>
  52. <th>realm.ldap.groupBase</th><td>OU=Groups,OU=UserControl,OU=MyOrganization,DC=MyDomain</td>
  53. <td>What is the root node for all teams in this LDAP system. Subtree searches will start from this node.</td>
  54. </tr>
  55. <tr>
  56. <th>realm.ldap.groupMemberPattern</th><td>(&(objectClass=group)(member=${dn}))</td><td>The LDAP search filter that will match all teams for the authenticating user. ${username} will be replaced with whatever the user enters as their username in the Gitblit login panel. Anything else in ${} will be replaced by Attributes from the User node.</td>
  57. </tr>
  58. <tr>
  59. <th>realm.ldap.admins</th><td>@Git_Admins</td><td>A space-delimited list of usernames and/or teams that indicate admin status in Gitblit. Teams are referenced with a leading <em>@</em> character.</td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. #### LDAP In-Memory Server
  64. You can start Gitblit GO with an in-memory LDAP server by specifying the *--ldapLdifFile* command-line argument. The LDAP server will listen on localhost of the port specified in *realm.ldap.url* of `gitblit.properties`. Additionally, a root user record is automatically created for *realm.ldap.username* and *realm.ldap.password*. Please note that the ldaps:// protocol is not supported for the in-memory server.
  65. ### Windows Authentication
  66. Windows authentication is based on the use of Waffle and JNA. It is known to work properly for authenticating against the local Windows machine, but it is unclear if it works properly with a domain controller and Active Directory. To use this service, your Gitblit server must be installed on a Windows machine.
  67. realm.userService = com.gitblit.WindowsUserService
  68. realm.windows.defaultDomain =
  69. ### Redmine Authentication
  70. You may authenticate your users against a Redmine installation as long as your Redmine install has properly enabled [API authentication](http://www.redmine.org/projects/redmine/wiki/Rest_Api#Authentication). This user service only supports user authentication; it does not support team creation based on Redmine groups. Redmine administrators will also be Gitblit administrators.
  71. realm.userService = com.gitblit.RedmineUserService
  72. realm.redmine.url = http://example.com/redmine
  73. ### Salesforce.com Authentication
  74. You may authenticate your users against Salesforce.com. You can require that user's belong to a particular organization by specifying a non-zero organization id.
  75. realm.userService = com.gitblit.SalesforceUserService
  76. realm.salesforce.orgId = 0
  77. ### Container Authentication
  78. If you are using the WAR variant and deploying into your own servlet container which has a pre-defined authentication mechanism protecting the Gitblit webapp, then you may instruct Gitblit to automatically create Gitblit accounts for container-authenticated user principals.
  79. realm.container.autoCreateAccounts = true
  80. ## Custom Authentication
  81. This is the simplest choice where you implement custom authentication and delegate all other standard user and team operations to one of Gitblit's user service implementations. This choice insulates your customization from changes in User and Team model classes and additional API that may be added to IUserService.
  82. Please subclass [com.gitblit.GitblitUserService](https://github.com/gitblit/gitblit/blob/master/src/main/java/com/gitblit/GitblitUserService.java) and override the *setup()* and *authenticate()* methods.
  83. Make sure to set the *serviceImpl* field in your *setup()* method.
  84. You may use your subclass by specifying its fully qualified classname in the *realm.userService* setting.
  85. Your subclass must be on Gitblit's classpath and must have a public default constructor.
  86. ### Custom Everything
  87. Instead of maintaining a `users.conf` file, you may want to integrate Gitblit into an existing environment.
  88. You may use your own custom *com.gitblit.IUserService* implementation by specifying its fully qualified classname in the *realm.userService* setting.
  89. Your user service class must be on Gitblit's classpath and must have a public default constructor.
  90. Please see the following interface definition [com.gitblit.IUserService](https://github.com/gitblit/gitblit/blob/master/src/main/java/com/gitblit/IUserService.java).