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.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 your 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 substituted with login name given on sign-in form.
  94. - Example: `cn=%s,ou=Users,dc=mydomain,dc=com`
  95. - Example: `uid=%s,ou=Users,dc=mydomain,dc=com`
  96. - User Filter **(required)**
  97. - An LDAP filter declaring when a user should be allowed to log in. The `%s`
  98. matching parameter will be substituted with login name given on sign-in
  99. form.
  100. - Example: `(&(objectClass=posixAccount)(cn=%s))`
  101. - Example: `(&(objectClass=posixAccount)(uid=%s))`
  102. **Verify group membership in LDAP** uses the following fields:
  103. * Group Search Base (optional)
  104. * The LDAP DN used for groups.
  105. * Example: `ou=group,dc=mydomain,dc=com`
  106. * Group Name Filter (optional)
  107. * An LDAP filter declaring how to find valid groups in the above DN.
  108. * Example: `(|(cn=gitea_users)(cn=admins))`
  109. * User Attribute in Group (optional)
  110. * Which user LDAP attribute is listed in the group.
  111. * Example: `uid`
  112. * Group Attribute for User (optional)
  113. * Which group LDAP attribute contains an array above user attribute names.
  114. * Example: `memberUid`
  115. ## PAM (Pluggable Authentication Module)
  116. To configure this you just need to set the 'PAM Service Name' to a filename in `/etc/pam.d/`.
  117. If you want it to work with normal Linux passwords, the user running Gitea must have read access to `/etc/shadow`.
  118. ## SMTP (Simple Mail Transfer Protocol)
  119. This option allows Gitea to log in to your SMTP host as a Gitea user. To configure this, simply set the fields below:
  120. - Authentication Name **(required)**
  121. - A name to assign to the new method of authorization.
  122. - SMTP Authentication Type **(required)**
  123. - Type of authentication for use on your SMTP host, PLAIN or LOGIN.
  124. - Host **(required)**
  125. - The address where the SMTP host can be reached.
  126. - Example: `smtp.mydomain.com`
  127. - Port **(required)**
  128. - The port to use when connecting to the server.
  129. - Example: `587`
  130. - Allowed Domains
  131. - Restrict what domains can log in if you're using public SMTP host or SMTP host with multiple domains.
  132. - Example: `gitea.io,mydomain.com,mydomain2.com`
  133. - Enable TLS Encryption
  134. - Enable TLS encryption on authentication.
  135. - Skip TLS Verify
  136. - Disable TLS verify on authentication.
  137. - This authentication is activate
  138. - Enable or disable this auth.
  139. ## FreeIPA
  140. - In order to log in to Gitea using FreeIPA credentials, you need to create a bind account for Gitea to use:
  141. - On the FreeIPA server, create a `gitea.ldif` file, replacing `dc=example,dc=com` with your DN, and providing an appropriately secure password:
  142. ```
  143. dn: uid=gitea,cn=sysaccounts,cn=etc,dc=example,dc=com
  144. changetype: add
  145. objectclass: account
  146. objectclass: simplesecurityobject
  147. uid: gitea
  148. userPassword: secure password
  149. passwordExpirationTime: 20380119031407Z
  150. nsIdleTimeout: 0
  151. ```
  152. - Import the LDIF (change localhost to an IPA server if needed), you’ll be prompted for your Directory Manager password:
  153. ```
  154. ldapmodify -h localhost -p 389 -x -D \
  155. "cn=Directory Manager" -W -f gitea.ldif
  156. ```
  157. - Add an IPA group for gitea_users :
  158. ```
  159. ipa group-add --desc="Gitea Users" gitea_users
  160. ```
  161. - Note: If you get an error about IPA credentials, please run `kinit admin` and give your admin account password.
  162. - Now login to the Gitea as an Administrator, click on "Authentication" under Admin Panel. Then click `Add New Source` and fill in the details, changing all where appropriate to your own domain.