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

authentication.en-us.md 7.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. ---
  2. date: "2016-12-01T16:00:00+02:00"
  3. title: "Authentication"
  4. slug: "authentication"
  5. weight: 10
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "features"
  11. name: "Authentication"
  12. weight: 10
  13. identifier: "authentication"
  14. ---
  15. ---
  16. name: Authentication
  17. ---
  18. # Authentication
  19. ## LDAP (Lightweight Directory Access Protocol)
  20. Both the LDAP via BindDN and the simple auth LDAP share the following fields:
  21. - Authorization Name **(required)**
  22. - A name to assign to the new method of authorization.
  23. - Host **(required)**
  24. - The address where the LDAP server can be reached.
  25. - Example: `mydomain.com`
  26. - Port **(required)**
  27. - The port to use when connecting to the server.
  28. - Example: `389` for LDAP or `636` for LDAP SSL
  29. - Enable TLS Encryption (optional)
  30. - Whether to use TLS when connecting to the LDAP server.
  31. - Admin Filter (optional)
  32. - An LDAP filter specifying if a user should be given administrator
  33. privileges. If a user account passes the filter, the user will be
  34. privileged as an administrator.
  35. - Example: `(objectClass=adminAccount)`
  36. - Example for Microsoft Active Directory (AD): `(memberOf=CN=admin-group,OU=example,DC=example,DC=org)`
  37. - Username attribute (optional)
  38. - The attribute of the user's LDAP record containing the user name. Given
  39. attribute value will be used for new Gitea account user name after first
  40. successful sign-in. Leave empty to use login name given on sign-in form.
  41. - This is useful when supplied login name is matched against multiple
  42. attributes, but only single specific attribute should be used for Gitea
  43. account name, see "User Filter".
  44. - Example: `uid`
  45. - Example for Microsoft Active Directory (AD): `sAMAccountName`
  46. - First name attribute (optional)
  47. - The attribute of the user's LDAP record containing the user's first name.
  48. This will be used to populate their account information.
  49. - Example: `givenName`
  50. - Surname attribute (optional)
  51. - The attribute of the user's LDAP record containing the user's surname.
  52. This will be used to populate their account information.
  53. - Example: `sn`
  54. - E-mail attribute **(required)**
  55. - The attribute of the user's LDAP record containing the user's email
  56. address. This will be used to populate their account information.
  57. - Example: `mail`
  58. **LDAP via BindDN** adds the following fields:
  59. - Bind DN (optional)
  60. - The DN to bind to the LDAP server with when searching for the user. This
  61. may be left blank to perform an anonymous search.
  62. - Example: `cn=Search,dc=mydomain,dc=com`
  63. - Bind Password (optional)
  64. - The password for the Bind DN specified above, if any. _Note: The password
  65. is stored in plaintext at the server. As such, ensure that the Bind DN
  66. has as few privileges as possible._
  67. - User Search Base **(required)**
  68. - The LDAP base at which user accounts will be searched for.
  69. - Example: `ou=Users,dc=mydomain,dc=com`
  70. - User Filter **(required)**
  71. - An LDAP filter declaring how to find the user record that is attempting to
  72. authenticate. The `%s` matching parameter will be substituted with login
  73. name given on sign-in form.
  74. - Example: `(&(objectClass=posixAccount)(uid=%s))`
  75. - Example for Microsoft Active Directory (AD): `(&(objectCategory=Person)(memberOf=CN=user-group,OU=example,DC=example,DC=org)(sAMAccountName=%s)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))`
  76. - To substitute more than once `%[1]s` should be used instead, e.g. when
  77. matching supplied login name against multiple attributes such as user
  78. identifier, email or even phone number.
  79. - Example: `(&(objectClass=Person)(|(uid=%[1]s)(mail=%[1]s)(mobile=%[1]s)))`
  80. - Enable user synchronization
  81. - This option enables a periodic task that synchronizes the Gitea users with
  82. the LDAP server. The default period is every 24 hours but that can be
  83. changed in the app.ini file. See the *cron.sync_external_users* section in
  84. the [sample
  85. app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.ini.sample)
  86. for detailed comments about that section. The *User Search Base* and *User
  87. Filter* settings described above will limit which users can use Gitea and
  88. which users will be synchronized. When initially run the task will create
  89. all LDAP users that match the given settings so take care if working with
  90. large Enterprise LDAP directories.
  91. **LDAP using simple auth** adds the following fields:
  92. - User DN **(required)**
  93. - A template to use as the user's DN. The `%s` matching parameter will be
  94. substituted with login name given on sign-in form.
  95. - Example: `cn=%s,ou=Users,dc=mydomain,dc=com`
  96. - Example: `uid=%s,ou=Users,dc=mydomain,dc=com`
  97. - User Filter **(required)**
  98. - An LDAP filter declaring when a user should be allowed to log in. The `%s`
  99. matching parameter will be substituted with login name given on sign-in
  100. form.
  101. - Example: `(&(objectClass=posixAccount)(cn=%s))`
  102. - Example: `(&(objectClass=posixAccount)(uid=%s))`
  103. **Verify group membership in LDAP** uses the following fields:
  104. * Group Search Base (optional)
  105. * The LDAP DN used for groups.
  106. * Example: `ou=group,dc=mydomain,dc=com`
  107. * Group Name Filter (optional)
  108. * An LDAP filter declaring how to find valid groups in the above DN.
  109. * Example: `(|(cn=gitea_users)(cn=admins))`
  110. * User Attribute in Group (optional)
  111. * Which user LDAP attribute is listed in the group.
  112. * Example: `uid`
  113. * Group Attribute for User (optional)
  114. * Which group LDAP attribute contains an array above user attribute names.
  115. * Example: `memberUid`
  116. ## PAM (Pluggable Authentication Module)
  117. To configure PAM, set the 'PAM Service Name' to a filename in `/etc/pam.d/`. To
  118. work with normal Linux passwords, the user running Gitea must have read access
  119. to `/etc/shadow`.
  120. ## SMTP (Simple Mail Transfer Protocol)
  121. This option allows Gitea to log in to an SMTP host as a Gitea user. To
  122. configure this, set the fields below:
  123. - Authentication Name **(required)**
  124. - A name to assign to the new method of authorization.
  125. - SMTP Authentication Type **(required)**
  126. - Type of authentication to use to connect to SMTP host, PLAIN or LOGIN.
  127. - Host **(required)**
  128. - The address where the SMTP host can be reached.
  129. - Example: `smtp.mydomain.com`
  130. - Port **(required)**
  131. - The port to use when connecting to the server.
  132. - Example: `587`
  133. - Allowed Domains
  134. - Restrict what domains can log in if using a public SMTP host or SMTP host
  135. with multiple domains.
  136. - Example: `gitea.io,mydomain.com,mydomain2.com`
  137. - Enable TLS Encryption
  138. - Enable TLS encryption on authentication.
  139. - Skip TLS Verify
  140. - Disable TLS verify on authentication.
  141. - This authentication is activate
  142. - Enable or disable this auth.
  143. ## FreeIPA
  144. - In order to log in to Gitea using FreeIPA credentials,a bind account needs to
  145. be created for Gitea:
  146. - On the FreeIPA server, create a `gitea.ldif` file, replacing `dc=example,dc=com`
  147. with your DN, and provide an appropriately secure password:
  148. ```
  149. dn: uid=gitea,cn=sysaccounts,cn=etc,dc=example,dc=com
  150. changetype: add
  151. objectclass: account
  152. objectclass: simplesecurityobject
  153. uid: gitea
  154. userPassword: secure password
  155. passwordExpirationTime: 20380119031407Z
  156. nsIdleTimeout: 0
  157. ```
  158. - Import the LDIF (change localhost to an IPA server if needed). A prompt for
  159. Directory Manager password will be presented:
  160. ```
  161. ldapmodify -h localhost -p 389 -x -D \
  162. "cn=Directory Manager" -W -f gitea.ldif
  163. ```
  164. - Add an IPA group for gitea\_users :
  165. ```
  166. ipa group-add --desc="Gitea Users" gitea_users
  167. ```
  168. - Note: For errors about IPA credentials, run `kinit admin` and provide the
  169. domain admin account password.
  170. - Log in to Gitea as an Administrator and click on "Authentication" under Admin Panel.
  171. Then click `Add New Source` and fill in the details, changing all where appropriate.