Skip to content

Commit 8cc6d14

Browse files
committed
Update the reverse proxy auth docs
1 parent e2042df commit 8cc6d14

File tree

2 files changed

+96
-11
lines changed

2 files changed

+96
-11
lines changed

content/en/v1/admin/config.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,10 @@ define('TOTP_ISSUER', 'Kanboard');
230230

231231
// Comma separated list of trusted proxy headers, for example: "HTTP_X_REAL_IP,HTTP_X_FORWARDED_FOR"
232232
define('TRUSTED_PROXY_HEADERS', '');
233+
234+
// Comma separated list of trusted proxy IP networks (CIDR), for example: "192.168.0.0/16,10.0.0.0/8,::1/128"
235+
define('TRUSTED_PROXY_NETWORKS', '');
236+
237+
// Allow private network access when fetching metadata for external links
238+
define('EXTERNAL_LINK_ALLOW_PRIVATE_NETWORKS', false);
233239
```

content/en/v1/admin/reverse_proxy_authentication.md

Lines changed: 90 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ menu:
88

99
This authentication method is often used for [SSO](http://en.wikipedia.org/wiki/Single_sign-on) (Single Sign-On), especially for large organizations.
1010

11-
The authentication is handled by another system. Kanboard does not store your password and assumes you are already authenticated.
11+
The authentication is handled by another system.
12+
Kanboard does not store your password and assumes you are already authenticated.
1213

1314
## Requirements
1415

15-
- Apache authentication on the same server or a properly configured reverse proxy.
16+
- Apache or another web server with authentication capabilities (e.g., Basic Auth, LDAP, OAuth, SAML)
17+
- A reverse proxy configured to authenticate users and forward authentication headers to Kanboard
18+
- Network configuration ensuring Kanboard is only accessible through the reverse proxy
1619

1720
## How Does This Work?
1821

@@ -25,15 +28,83 @@ The authentication is handled by another system. Kanboard does not store your pa
2528

2629
### Setting Up Your Reverse Proxy
2730

28-
This is outside the scope of this documentation. Ensure the reverse proxy sends the user login via an HTTP header and identify which header is used.
31+
This is outside the scope of this documentation. You must configure your reverse proxy to authenticate users and pass the authenticated username via an HTTP header to Kanboard.
32+
33+
Consult your reverse proxy documentation to:
34+
35+
- Enable authentication (e.g., Basic Auth, LDAP, OAuth, SAML)
36+
- Configure the proxy to set an HTTP header containing the authenticated username
37+
- Identify which header name your proxy uses (e.g., `REMOTE_USER`, `X-Forwarded-User`, `X-Authenticated-User`)
38+
39+
You will need this header name for the Kanboard configuration below.
40+
41+
#### Security (important): prevent authentication header spoofing
42+
43+
When reverse proxy authentication is enabled, Kanboard trusts the configured header (for example `REMOTE_USER` or `HTTP_X_AUTHENTICATED_USER`).
44+
If an attacker can reach Kanboard directly (bypassing the reverse proxy) or can inject headers that your proxy forwards, they could impersonate another user.
45+
46+
To avoid this, configure your reverse proxy so that:
47+
48+
- Kanboard is not reachable directly from untrusted networks (only through the reverse proxy).
49+
- The proxy removes any incoming authentication headers from the client request.
50+
- The proxy sets the authentication header itself, using a value coming from the proxy authentication step.
51+
52+
Nginx example (strip client-supplied headers, then set your own):
53+
54+
```nginx
55+
location / {
56+
# Strip any client-supplied authentication headers to prevent spoofing
57+
proxy_set_header X-Forwarded-User "";
58+
proxy_set_header REMOTE_USER "";
59+
60+
# Set the authentication header from the authenticated user
61+
# For HTTP Basic Auth, use $remote_user
62+
proxy_set_header X-Forwarded-User $remote_user;
63+
64+
# For auth_request module, use a variable from your auth subrequest:
65+
# proxy_set_header X-Forwarded-User $auth_user;
66+
67+
# Forward other standard headers
68+
proxy_set_header Host $host;
69+
proxy_set_header X-Real-IP $remote_addr;
70+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
71+
proxy_set_header X-Forwarded-Proto $scheme;
72+
73+
proxy_pass http://kanboard_upstream;
74+
}
75+
```
76+
77+
Apache example (unset, then set from the authenticated user):
78+
79+
```apache
80+
# Strip any client-supplied authentication headers to prevent spoofing
81+
RequestHeader unset X-Forwarded-User
82+
RequestHeader unset REMOTE_USER
83+
84+
# Set the authentication header from the authenticated user
85+
# This example assumes Apache HTTP Basic Auth or similar module
86+
RequestHeader set X-Forwarded-User "%{REMOTE_USER}e"
87+
88+
# Alternative: if using mod_auth_openidc or similar OAuth/OIDC module:
89+
# RequestHeader set X-Forwarded-User "%{OIDC_CLAIM_preferred_username}e"
90+
```
91+
92+
Also ensure the upstream Kanboard server only accepts connections from the reverse proxy (for example, firewall rules, binding Kanboard to `127.0.0.1`, or allowing only the proxy IP).
2993

3094
### Setting Up Kanboard
3195

32-
Create a custom `config.php` file or copy the `config.default.php` file:
96+
Since Kanboard version 1.2.49, it is mandatory to configure the `TRUSTED_PROXY_NETWORKS` option when enabling reverse proxy authentication.
97+
This setting specifies the list of trusted proxy networks in CIDR format that are permitted to set the authentication header.
98+
99+
For instance, if your reverse proxy operates on the same server as Kanboard, you can configure it as follows: `127.0.0.1/32,::1/128`.
33100

34101
```php
35-
<?php
102+
define('TRUSTED_PROXY_NETWORKS', '127.0.0.1/32,::1/128');
103+
```
36104

105+
Then, enable reverse proxy authentication by adding the following configuration to your `config.php` file.
106+
107+
```php
37108
// Enable/disable reverse proxy authentication
38109
define('REVERSE_PROXY_AUTH', true); // Set this value to true
39110

@@ -57,9 +128,17 @@ define('REVERSE_PROXY_EMAIL_HEADER', 'REMOTE_EMAIL');
57128
define('REVERSE_PROXY_FULLNAME_HEADER', 'REMOTE_NAME');
58129
```
59130

60-
{{< hint type="info" >}}
61-
- If the proxy is the same web server that runs Kanboard, according to the [CGI protocol](http://www.ietf.org/rfc/rfc3875), the header name will be `REMOTE_USER`. For example, Apache adds `REMOTE_USER` by default if `Require valid-user` is set.
62-
- If you use a different header for `REVERSE_PROXY_USER_HEADER`, the value must be prefixed by `HTTP_`, all hyphens must be replaced by underscores, and the string must be in all capitals because it is fetched from the `$_SERVER` array. For example, `X-Proxy-Username` becomes `HTTP_X_PROXY_USERNAME`.
63-
- If Apache is a reverse proxy to another Apache running Kanboard, the header `REMOTE_USER` is not set (the same behavior applies to IIS and Nginx).
64-
- If you have a real reverse proxy, the [HTTP ICAP draft](http://tools.ietf.org/html/draft-stecher-icap-subid-00#section-3.4) proposes the header to be `X-Authenticated-User`. This de facto standard has been adopted by several tools.
65-
{{</ hint >}}
131+
#### Custom Header Names
132+
133+
If you want to use a custom HTTP header for `REVERSE_PROXY_USER_HEADER` option, you must follow PHP's `$_SERVER` variable naming convention:
134+
135+
1. Prefix the header name with `HTTP_`
136+
2. Convert to uppercase
137+
3. Replace hyphens with underscores
138+
139+
**Examples:**
140+
141+
- `X-Proxy-Username``HTTP_X_PROXY_USERNAME`
142+
- `X-Authenticated-User``HTTP_X_AUTHENTICATED_USER`
143+
144+
**Note:** The standard `REMOTE_USER` header is an exception and does not require the `HTTP_` prefix.

0 commit comments

Comments
 (0)