- Admin Panel: Navigate to Admin Panel > Authentication Sources
- Configuration files: Place
.conffiles in thecustom/conf/auth.d/directory. Each file describes one source using INI format. Files are loaded once at startup and keyed byid. See the “Configuration file” subsection under each backend below for examples.
LDAP
Gogs supports two variants of LDAP authentication: Simple Auth and Bind DN. In both cases, authentication is performed by attempting to bind to the LDAP server with the User DN and password. The difference is that with Bind DN, a preliminary query is performed (using the Bind DN credentials) to find the User DN first.- When to use Bind DN
- When to use Simple Auth
The Bind DN mechanism has these advantages:
- It may be more secure than blindly attempting to bind with a possibly non-existent User DN.
- It supports login with attributes such as email address or phone number. The preliminary search can look up the User DN using
mailormobileattributes. - It is required when the LDAP does not allow the User DN to query its own attributes or group memberships.
Shared fields
The following fields are shared between both Bind DN and Simple Auth configurations:Simple Auth fields
LDAP via Simple Auth adds the following field:Bind DN fields
LDAP via Bind DN adds the following fields:Group membership verification
You can optionally verify LDAP group membership using the following fields:Configuration files
LDAP sources can also be defined as.conf files in custom/conf/auth.d/ instead of through the admin panel. Files are loaded at startup and keyed by id.
- Bind DN
- Simple Auth
FreeIPA examples
It is possible to use either Bind DN or Simple Auth with FreeIPA. The examples below assume your domain isdomain.com and that users must be a member of the gogs_users group to get access.
FreeIPA with Simple Auth
FreeIPA with Simple Auth
Setting up access using Simple Auth is straightforward:
FreeIPA with Bind DN
FreeIPA with Bind DN
If you want to allow login by email address, note that FreeIPA by default does not grant anonymous search access to the Alternatively, you can ask your LDAP administrators for a dedicated bind user account.More precisely, Gogs maps the login name onto the user’s “Authentication Login Name”, which administrators can edit on the user’s Edit Account page.
mail attribute. This can be changed in IPA:Allowing email-based login via Bind DN may no longer be necessary. Gogs translates email logins to the corresponding user ID before making the authentication call to the backend LDAP. The only requirement is that the user’s first login is with their user ID. After that, they can use either user ID or email address.
PAM
To configure PAM authentication, set the PAM Service Name to a filename in/etc/pam.d/.
Configuration file
SMTP
SMTP authentication allows Gogs to log in to your SMTP host to verify user credentials. Configure the following fields:Configuration file
HTTP header
If your reverse proxy already handles user authentication (e.g. via SSO, OAuth, or client certificates), Gogs can trust the authenticated username from an HTTP header. This is configured incustom/conf/app.ini under [auth]:
When auto-registration is enabled, Gogs creates new accounts with an activated status and a placeholder email address. The user can update their email after first login.