You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gogs supports authentication by various external sources. Currently supported are: LDAP, SMTP, PAM, and GitHub. Sources can be configured in **Admin Panel - Authentication Sources**, or (starting from `0.11.45.0412`) using configuration files in `custom/conf/auth.d`.
8
8
9
-
Starting from `0.11.45.0412`, you can define the authentication source in local files to help better automate setup process.
9
+
## Using configuration files
10
10
11
-
Files with the suffix `.conf` under `conf/auth.d`of the custom directory will be recognized as authentication sources. For example, `custom/conf/auth.d/my_auth_source.conf`. As long as the file name ends with `.conf`, you can name it anything memorable. You can find examples of all supported types [here](https://github.com/gogs/gogs/tree/f2ecfdc96a338815ffb2be898b3114031f0da48c/conf/auth.d).
11
+
Since version `0.11.45.0412`, files with the suffix `.conf` under `custom/conf/auth.d` will be recognized as authentication sources. An example for each of the supported sources can be found [here](https://github.com/gogs/gogs/tree/master/conf/auth.d).
12
12
13
-
Once files are loaded, they will appear in the **Admin Panel - Authentication Sources**page as before. They also work nicely with authentication sources defined in the database.
13
+
Authentication sources defined via configuration files appear in the **Admin Panel - Authentication Sources**just like sources created via the web interface.
14
14
15
15

16
16
17
-
However, do not try to edit the file directly. Rather, edit it via the web interface because files are only read once when Gogs starts.
17
+
Configuration files are read once when Gogs starts. To edit them while Gogs is running, use the web interface.
18
18
19
19
## Configuration
20
20
21
21
### LDAP
22
22
23
-
Both the LDAP via BindDN and the simple auth LDAP share the following fields:
23
+
There are two variants for LDAP authentication: with or without a separate Bind DN. In both cases authentication is performed by attempting to bind to the LDAP with the User DN and password. The difference is that with the Bind DN, a query is first performed (by the Bind DN) to find the User DN.
24
24
25
-
- Authorization Name **(required)**
26
-
- A name to assign to the new method of authorization.
25
+
The Bind DN mechanism has these advantages:
26
+
27
+
- It may be more secure than blindy attempting to bind with a possibly non-existent User DN
28
+
- It supports login with e.g. email address or phone number. The preliminary search could look up the User DN using their `mail` or `mobile` attribute (but see the FreeIPA section further down: features in Gogs may have obsoleted the need for this)
29
+
- A Bind DN is required when the LDAP does not allow the User DN to query its own attributes or group memberships
30
+
31
+
The downside to the Bind DN mechanism is that, unless the LDAP allows anonymous queries, it requires a bind DN to be defined in the LDAP, and Gogs needs to store its credentials. Gogs currently does not encrypt these.
32
+
33
+
In the ideal situation, the LDAP allows anonymous queries (at least in the "user container") and the Bind DN mechanism can be used without a Bind DN and password. The options available to you depend on how the LDAP in your organisation has been configured.
34
+
35
+
**Shared configuration fields** between _Bind DN_ and _Simple Auth_ authentication
36
+
37
+
- Authentication Name **(required)**
38
+
- A friendly name to assign to the new authentication source
39
+
40
+
- Security Protocol **(required)**
41
+
- Unencrypted (0), LDAPS (1), StartTLS (2)
27
42
28
43
- Host **(required)**
29
44
- The address where the LDAP server can be reached.
30
-
- Example: `mydomain.com`
45
+
- Example: `ldap.mydomain.com`
31
46
32
47
- Port **(required)**
33
48
- The port to use when connecting to the server.
34
-
-Example: `636`
49
+
-Usually `389` for the LDAP and StartTLS protocols, `636` for LDAPS protocol.
35
50
36
-
- Enable TLS Encryption (optional)
37
-
- Whether to use TLS when connecting to the LDAP server.
51
+
- User Filter **(required)**
52
+
- An LDAP filter declaring which users should be allowed to log in. Used as the
53
+
initial search query in the Bind DN authenticator. Applied "on top of" the
54
+
authenticated user context in Simple Authentication. The `%s` matching parameter
55
+
will be substituted with the login name given on the sign-in form.
- To substitute more than once, e.g. when matching a supplied login name against multiple attributes such as user identifier, email, or even phone number.
- Import the LDIF (change `localhost` to an IPA server if needed). You will be prompted for your Directory Manager password:
178
-
```
179
-
ldapmodify -h localhost -p 389 -x -D \
180
-
"cn=Directory Manager" -W -f gogs.ldif
181
-
```
182
-
- Add an IPA group for `gogs_users`:
183
-
```
184
-
ipa group-add --desc="Gogs Users" gogs_users
185
-
```
186
-
- Note! If you get an error about IPA credentials, run kinit admin and give your admin accound password.
187
-
188
-
- Now log into Gogs as admin and click on "Authentication" under the Admin Panel. Then click *New LDAP Source* and fill in the details, changing all appropriate fields for your own domain as shown below:
189
-
190
-

177
+
It is possible to use either Bind DN or Simple Auth with FreeIPA. Below are
178
+
the relevant parts of sample configurations. These assume that your domain is
179
+
`domain.com`, and that users must be a member of group `gogs_users` to get access.
0 commit comments