1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
---
title: "Proxy Authorization"
description: "A reference guide on Proxy Authorization implementations"
summary: "This section contains reference guide on Proxy Authorization implementations Authelia supports."
date: 2023-01-25T20:36:40+11:00
draft: false
images: []
menu:
reference:
parent: "guides"
weight: 220
toc: true
aliases:
- /r/proxy-authz
seo:
title: "" # custom title (optional)
description: "" # custom description (recommended)
canonical: "" # custom canonical URL (optional)
noindex: false # false (default) or true
---
Proxies can integrate with Authelia via several authorization endpoints. These endpoints are by default configured
appropriately for most use cases; however they can be individually configured, removed, added, etc.
They are currently divided into two sections:
- [Implementations](#implementations)
- [Authn Strategies](#authn-strategies)
These endpoints are meant to collect important information from these requests via headers to determine both
metadata about the request (such as the resource and IP address of the user) which is determined via the
[Implementations](#implementations), and the identity of the user which is determined via the
[Authn Strategies](#authn-strategies).
## Default Endpoints
| Name | Path | [Implementation] | [Authn Strategies] |
|:------------:|:-----------------------:|:----------------:|:--------------------------------------:|
| forward-auth | /api/authz/forward-auth | [ForwardAuth] | [HeaderAuthorization], [CookieSession] |
| ext-authz | /api/authz/ext-authz | [ExtAuthz] | [HeaderAuthorization], [CookieSession] |
| auth-request | /api/authz/auth-request | [AuthRequest] | [HeaderAuthorization], [CookieSession] |
| legacy | /api/verify | [Legacy] | [HeaderLegacy], [CookieSession] |
## Metadata
Various metadata is collected from the request made to the Authelia authorization server. This table describes the
metadata collected. All of this metadata is utilized for the purpose of determining if the user is authorized to a
particular resource.
| Name | Description |
|:------------:|:-----------------------------------------------:|
| Method | The Method Verb of the Request |
| Scheme | The URI Scheme of the Request |
| Hostname | The URI Hostname of the Request |
| Path | The URI Path of the Request |
| IP | The IP address of the client making the Request |
| Authelia URL | The URL of the Authelia Portal |
Some values may have either fallbacks or override values. If they exist they will be in the alternatives table which
will be below the main metadata table.
The metadata table contains the recommended source of this information and this source is often times automatic
depending on the proxy implementation. The difference between an override and a fallback is an override values will
take precedence over the metadata values, and fallbacks only take effect if the override values or metadata values are
completely unset.
## Implementations
### ForwardAuth
This is the implementation which supports [Traefik] via the [ForwardAuth Middleware], [Caddy] via the
[forward_auth directive], [HAProxy] via the [auth-request lua plugin], and [Skipper] via the [webhook auth filter].
#### ForwardAuth Metadata
| Metadata | Source | Key |
|:-----------------:|:----------------------------:|:-------------------------:|
| Method [^1] | [Header] | `X-Forwarded-Method` [^2] |
| Scheme [^1] | [Header] | [X-Forwarded-Proto] [^2] |
| Hostname [^1] | [Header] | [X-Forwarded-Host] [^2] |
| Path [^1] | [Header] | `X-Forwarded-URI` [^2] |
| IP [^1] | [Header] | [X-Forwarded-For] [^3] |
| Authelia URL [^1] | Session Cookie Configuration | `authelia_url` |
#### ForwardAuth Metadata Alternatives
| Metadata | Alternative Type | Source | Key |
|:-----------------:|:----------------:|:--------------:|:--------------:|
| Scheme [^1] | Fallback | [Header] | Server Scheme |
| IP [^1] | Fallback | TCP Packet | Source IP |
| Authelia URL [^1] | Override | Query Argument | `authelia_url` |
### ExtAuthz
This is the implementation which supports [Envoy] via the [HTTP ExtAuthz Filter].
#### ExtAuthz Metadata
| Metadata | Source | Key |
|:-----------------:|:----------------------------:|:------------------------:|
| Method [^1] | _[Start Line]_ | [HTTP Method] [^2] |
| Scheme [^1] | [Header] | [X-Forwarded-Proto] [^2] |
| Hostname [^1] | [Header] | [Host] [^2] |
| Path [^1] | [Header] | Endpoint Sub-Path [^2] |
| IP [^1] | [Header] | [X-Forwarded-For] [^2] |
| Authelia URL [^1] | Session Cookie Configuration | `authelia_url` |
#### ExtAuthz Metadata Alternatives
| Metadata | Alternative Type | Source | Key |
|:-----------------:|:----------------:|:----------:|:----------------:|
| Scheme [^1] | Fallback | [Header] | Server Scheme |
| IP [^1] | Fallback | TCP Packet | Source IP |
| Authelia URL [^1] | Override | [Header] | `X-Authelia-URL` |
### AuthRequest
This is the implementation which supports [NGINX] via the [auth_request HTTP module], and can technically support
[HAProxy] via the [auth-request lua plugin].
#### AuthRequest Metadata
| Metadata | Source | Key |
|:-----------------:|:----------------------------:|:------------------------:|
| Method [^1] | [Header] | `X-Original-Method` [^2] |
| Scheme [^1] | [Header] | `X-Original-URL` [^2] |
| Hostname [^1] | [Header] | `X-Original-URL` [^2] |
| Path [^1] | [Header] | `X-Original-URL` [^2] |
| IP [^1] | [Header] | [X-Forwarded-For] [^3] |
| Authelia URL [^1] | Session Cookie Configuration | `authelia_url` |
{{< callout context="note" title="Note" icon="outline/info-circle" >}}
This endpoint does not support automatic redirection. This is because there is no support on [NGINX](https://www.nginx.com/)'s side
to achieve this with `ngx_http_auth_request_module` and the redirection must be performed within the [NGINX](https://www.nginx.com/)
configuration. However, we return the appropriate URL to redirect users to with the `Location` header which
simplifies this process especially for multi-cookie domain deployments.
{{< /callout >}}
#### AuthRequest Metadata Alternatives
| Metadata | Alternative Type | Source | Key |
|:-----------------:|:----------------:|:--------------:|:--------------:|
| IP [^1] | Fallback | TCP Packet | Source IP |
| Authelia URL [^1] | Override | Query Argument | `authelia_url` |
### Legacy
This is the legacy implementation which used to operate similar to both the [ForwardAuth](#forwardauth) and
[AuthRequest](#authrequest) implementations.
{{< callout context="note" title="Note" icon="outline/info-circle" >}}
This implementation has duplicate entries for metadata. This is due to the fact this implementation used to
cater for the AuthRequest and ForwardAuth implementations. The table is in order of precedence where if a header higher
in the list exists it is used over those lower in the list.
{{< /callout >}}
| Metadata | Source | Key |
|:-----------------:|:--------------:|:--------------------:|
| Method [^1] | [Header] | `X-Original-Method` |
| Scheme [^1] | [Header] | `X-Original-URL` |
| Hostname [^1] | [Header] | `X-Original-URL` |
| Path [^1] | [Header] | `X-Original-URL` |
| Method [^1] | [Header] | `X-Forwarded-Method` |
| Scheme [^1] | [Header] | [X-Forwarded-Proto] |
| Hostname [^1] | [Header] | [X-Forwarded-Host] |
| Path [^1] | [Header] | `X-Forwarded-URI` |
| IP [^1] | [Header] | [X-Forwarded-For] |
| Authelia URL [^1] | Query Argument | `rd` |
| Authelia URL [^1] | [Header] | `X-Authelia-URL` |
## Authn Strategies
Authentication strategies are used to determine the users identity which is essential to determining if they are
authorized to visit a particular resource. Authentication strategies are executed in order, and have three potential
results.
1. Successful Authentication
- This result occurs when the required metadata i.e. headers are in the request for the strategy and they can be
validated.
- This result causes a short-circuit which generally results in a [200 OK].
2. Unsuccessful Authentication
- This result occurs when the required metadata i.e. headers are in the request for the strategy and they can not be
validated as they are either explicitly invalid or the means of validation could not be attempted due to an error.
- This result causes a short-circuit applying the failure action and no other strategies will be attempted.
3. No Authentication
- This result occurs when the required metadata i.e. headers are absent from the request for the strategy.
- This result does not cause a short-circuit and:
1. The next strategy will be attempted.
2. If there is no next strategy the failure action will be applied.
### CookieSession
**Failure Action:** Redirect the user for authentication.
**Metadata:** [Cookie] header value, considered absent when the configured cookie key is absent from this header or the
header is absent.
This strategy uses a cookie which links the user to a session to determine the users identity. This is the default
strategy for end-users.
### HeaderAuthorization
**Failure Action:** Responds with the [WWW-Authenticate] header and a [401 Unauthorized] status code.
**Metadata:** [Authorization] header, considered absent when the header is absent.
This strategy uses the [Authorization] header to determine the users' identity.
### HeaderProxyAuthorization
**Failure Action:** Responds with the [Proxy-Authenticate] header and a [407 Proxy Authentication Required] status code.
**Metadata:** [Proxy-Authorization] header, considered absent when the header is absent.
This strategy uses the [Proxy-Authorization] header to determine the users' identity.
### HeaderAuthRequestProxyAuthorization
**Failure Action:** Responds with the [WWW-Authenticate] header and a [401 Unauthorized] status code.
**Metadata:** [Proxy-Authorization] header, considered absent when the header is absent.
This strategy uses the [Proxy-Authorization] header to determine the users' identity. It is specifically intended for
use with the [AuthRequest] implementation.
### HeaderLegacy
**Failure Action:** Responds with the [WWW-Authenticate] header and a [401 Unauthorized] status code.
**Metadata:** [Proxy-Authorization] header, considered absent when the header is absent.
This strategy uses the [Proxy-Authorization] header to determine the users' identity.
## Footnotes
[^1]: This is considered required metadata, and must either be provided via the primary metadata source or the
alternative source for the request to be considered valid.
[^2]: This is considered a required header. If an alternative or fallback source is described this is very likely to
be incorrect and cannot be supported.
[^3]: This header is not required but the fallback is likely desirable in most scenarios.
[200 OK]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200
[401 Unauthorized]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
[407 Proxy Authentication Required]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407
[NGINX]: https://www.nginx.com/
[Traefik]: https://traefik.io/traefik/
[Envoy]: https://www.envoyproxy.io/
[Caddy]: https://caddyserver.com/
[Skipper]: https://opensource.zalando.com/skipper/
[HAProxy]: http://www.haproxy.org/
[HTTP ExtAuthz Filter]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ext_authz/v3/ext_authz.proto#envoy-v3-api-msg-extensions-filters-http-ext-authz-v3-extauthz
[auth_request HTTP module]: https://nginx.org/en/docs/http/ngx_http_auth_request_module.html
[auth-request lua plugin]: https://github.com/TimWolla/haproxy-auth-request
[ForwardAuth Middleware]: https://doc.traefik.io/traefik/middlewares/http/forwardauth/
[forward_auth directive]: https://caddyserver.com/docs/caddyfile/directives/forward_auth
[webhook auth filter]: https://opensource.zalando.com/skipper/reference/filters/#webhook
[Implementation]: #implementations
[Authn Strategies]: #authn-strategies
[ForwardAuth]: #forwardauth
[ExtAuthz]: #extauthz
[AuthRequest]: #authrequest
[Legacy]: #legacy
[HeaderProxyAuthorization]: #headerproxyauthorization
[HeaderAuthRequestProxyAuthorization]: #headerauthrequestproxyauthorization
[HeaderLegacy]: #headerlegacy
[HeaderAuthorization]: #headerauthorization
[CookieSession]: #cookiesession
[Cookie]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie
[Authorization]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization
[WWW-Authenticate]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate
[Proxy-Authorization]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization
[Proxy-Authenticate]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authenticate
[X-Forwarded-Proto]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
[X-Forwarded-Host]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host
[X-Forwarded-For]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
[Host]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host
[HTTP Method]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
[HTTP Method]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
[Start Line]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages#start_line
[Header]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
|