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

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