Overview
Gitea supports multiple authentication methods including LDAP, OAuth2, SMTP, and PAM. Authentication sources can be managed through the web interface or command-line.Managing Authentication Sources
List Authentication Sources
View all configured authentication sources:Delete Authentication Source
Remove an authentication source by ID:LDAP Authentication
Gitea supports two LDAP authentication modes:- Bind DN - Search for users using a service account
- Simple Auth - Authenticate directly with user credentials
LDAP via Bind DN
Add LDAP Source
Update LDAP Source
LDAP Configuration Options
Authentication source name
Security protocol:
unencrypted, ldaps, or starttlsLDAP server hostname or IP address
LDAP server port (typically 389 for LDAP, 636 for LDAPS)
DN to bind to the LDAP server (Bind DN mode only)
Password for the bind DN (Bind DN mode only)
LDAP base DN where user accounts are searched
LDAP filter to find user records. Use
%s as placeholder for username.
Example: (&(objectClass=inetOrgPerson)(uid=%s))LDAP attribute containing the username (e.g.,
uid, sAMAccountName)LDAP attribute for first name (e.g.,
givenName)LDAP attribute for surname (e.g.,
sn)LDAP attribute for email address (e.g.,
mail)LDAP attribute containing SSH public keys
LDAP attribute containing user avatar image
LDAP filter to identify admin users
LDAP filter to identify restricted users
Skip TLS certificate verification (not recommended for production)
Enable periodic user synchronization
LDAP search page size for pagination
Group Mapping
Map LDAP groups to Gitea organization teams:LDAP Simple Auth
For LDAP servers where you can construct the user DN directly:OAuth2 Authentication
Configure OAuth2 providers like GitHub, GitLab, Google, or custom OpenID Connect providers.Add OAuth2 Source
OAuth2 Configuration Options
Authentication source display name
OAuth2 provider:
github, gitlab, google, azure, bitbucket, discord, gitea, openidConnect, etc.OAuth2 client ID
OAuth2 client secret
OpenID Connect auto-discovery URL (required for
openidConnect provider)Comma-separated OAuth2 scopes to request
Custom icon URL for the login button
Skip Gitea’s 2FA for users authenticated via this source
Custom OAuth2 Endpoints
For self-hosted OAuth2 providers:OAuth2 Claims and Groups
Update OAuth2 Source
SMTP Authentication
Allow users to authenticate using their email credentials via SMTP.Add SMTP Source
SMTP Configuration Options
Authentication source name
SMTP authentication type:
PLAIN, LOGIN, or CRAM-MD5SMTP server hostname
SMTP server port (typically 25, 465, or 587)
Force SMTPS on all ports (normally only port 465)
Skip TLS certificate verification
Hostname sent with HELO command (defaults to current hostname)
Disable SMTP HELO command
Comma-separated list of allowed email domains. Leave empty to allow all.
Update SMTP Source
Configuration via app.ini
While the CLI is recommended, you can also configure authentication inapp.ini:
Two-Factor Authentication
Configure 2FA policies:Testing Authentication
After configuring an authentication source:Best Practices
- Use LDAPS/StartTLS: Always encrypt LDAP connections in production
- Restrict Filters: Use LDAP filters to limit which users can authenticate
- Test Separately: Test authentication sources in a non-production environment first
- Group Mapping: Use group mapping to automatically assign team memberships
- Monitor Sync: Enable user synchronization to keep LDAP users up-to-date
- Backup Sources: Export authentication configuration before making changes