gitea

Development moved to Codeberg


date: "2016-12-01T16:00:00+02:00" title: "Authentication" slug: "authentication" weight: 10 toc: false draft: false menu: sidebar: parent: "features" name: "Authentication" weight: 10

identifier: "authentication"

Authentication

{{< toc >}}

LDAP (Lightweight Directory Access Protocol)

Both the LDAP via BindDN and the simple auth LDAP share the following fields:

LDAP via BindDN

Adds the following fields:

LDAP using simple auth

Adds the following fields:

Verify group membership in LDAP

Uses the following fields:

PAM (Pluggable Authentication Module)

This procedure enables PAM authentication. Users may still be added to the system manually using the user administration. PAM provides a mechanism to automatically add users to the current database by testing them against PAM authentication. To work with normal Linux passwords, the user running Gitea must also have read access to /etc/shadow in order to check the validity of the account when logging in using a public key.

Note: If a user has added SSH public keys into Gitea, the use of these keys may bypass the login check system. Therefore, if you wish to disable a user who authenticates with PAM, you should also manually disable the account in Gitea using the built-in user manager.

  1. Configure and prepare the installation.
    • It is recommended that you create an administrative user.
    • Deselecting automatic sign-up may also be desired.
  2. Once the database has been initialized, log in as the newly created administrative user.
  3. Navigate to the user setting (icon in top-right corner), and select Site Administration -> Authentication Sources, and select Add Authentication Source.
  4. Fill out the field as follows:
    • Authentication Type : PAM
    • Name : Any value should be valid here, use "System Authentication" if you'd like.
    • PAM Service Name : Select the appropriate file listed under /etc/pam.d/ that performs the authentication desired.[^1]
    • PAM Email Domain : The e-mail suffix to append to user authentication. For example, if the login system expects a user called gituser, and this field is set to mail.com, then Gitea will expect the user email field for an authenticated GIT instance to be gituser@mail.com.[^2]

Note: PAM support is added via build-time flags, and the official binaries provided do not have this enabled. PAM requires that the necessary libpam dynamic library be available and the necessary PAM development headers be accessible to the compiler.

[^1]: For example, using standard Linux log-in on Debian "Bullseye" use common-session-noninteractive - this value may be valid for other flavors of Debian including Ubuntu and Mint, consult your distribution's documentation. [^2]: This is a required field for PAM. Be aware: In the above example, the user will log into the Gitea web interface as gituser and not gituser@mail.com

SMTP (Simple Mail Transfer Protocol)

This option allows Gitea to log in to an SMTP host as a Gitea user. To configure this, set the fields below:

FreeIPA

  dn: uid=gitea,cn=sysaccounts,cn=etc,dc=example,dc=com
  changetype: add
  objectclass: account
  objectclass: simplesecurityobject
  uid: gitea
  userPassword: secure password
  passwordExpirationTime: 20380119031407Z
  nsIdleTimeout: 0
  ldapmodify -h localhost -p 389 -x -D \
  "cn=Directory Manager" -W -f gitea.ldif
  ipa group-add --desc="Gitea Users" gitea_users

SPNEGO with SSPI (Kerberos/NTLM, for Windows only)

Gitea supports SPNEGO single sign-on authentication (the scheme defined by RFC4559) for the web part of the server via the Security Support Provider Interface (SSPI) built in Windows. SSPI works only in Windows environments - when both the server and the clients are running Windows.

Before activating SSPI single sign-on authentication (SSO) you have to prepare your environment:

  setspn -A HTTP/host.domain.local domain\user