2019-02-26 13:50:07 +00:00
|
|
|
# ForwardAuth
|
|
|
|
|
2019-03-20 15:36:10 +00:00
|
|
|
Using an External Service to Check for Credentials
|
2019-02-26 13:50:07 +00:00
|
|
|
{: .subtitle }
|
|
|
|
|
|
|
|
![AuthForward](../assets/img/middleware/authforward.png)
|
|
|
|
|
|
|
|
The ForwardAuth middleware delegate the authentication to an external service.
|
|
|
|
If the service response code is 2XX, access is granted and the original request is performed.
|
|
|
|
Otherwise, the response from the authentication server is returned.
|
|
|
|
|
|
|
|
## Configuration Examples
|
|
|
|
|
|
|
|
??? example "File -- Forward authentication to authserver.com"
|
|
|
|
|
|
|
|
```toml
|
2019-03-14 08:30:04 +00:00
|
|
|
[http.middlewares]
|
|
|
|
[http.middlewares.test-auth.forwardauth]
|
2019-02-26 13:50:07 +00:00
|
|
|
address = "https://authserver.com/auth"
|
|
|
|
trustForwardHeader = true
|
|
|
|
authResponseHeaders = ["X-Auth-User", "X-Secret"]
|
|
|
|
|
2019-03-14 08:30:04 +00:00
|
|
|
[http.middlewares.test-auth.forwardauth.tls]
|
2019-02-26 13:50:07 +00:00
|
|
|
ca = "path/to/local.crt"
|
|
|
|
caOptional = true
|
|
|
|
cert = "path/to/foo.cert"
|
|
|
|
key = "path/to/foo.key"
|
|
|
|
```
|
|
|
|
|
|
|
|
??? example "Docker -- Forward authentication to authserver.com"
|
|
|
|
|
|
|
|
```yml
|
|
|
|
a-container:
|
|
|
|
image: a-container-image
|
|
|
|
labels:
|
2019-03-14 08:30:04 +00:00
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.Address=https://authserver.com/auth"
|
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.AuthResponseHeaders=X-Auth-User, X-Secret"
|
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.TLS.CA=path/to/local.crt"
|
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.TLS.CAOptional=true"
|
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.TLS.Cert=path/to/foo.cert"
|
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.TLS.InsecureSkipVerify=true"
|
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.TLS.Key=path/to/foo.key"
|
|
|
|
- "traefik.http.middlewares.test-auth.ForwardAuth.TrustForwardHeader=true"
|
2019-02-26 13:50:07 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration Options
|
|
|
|
|
|
|
|
### address
|
|
|
|
|
|
|
|
The `address` option defines the authentication server address.
|
|
|
|
|
|
|
|
### trustForwardHeader
|
|
|
|
|
|
|
|
Set the `trustForwardHeader` option to true to trust all the existing X-Forwarded-* headers.
|
|
|
|
|
|
|
|
### authResponseHeaders
|
|
|
|
|
|
|
|
The `authResponseHeaders` option is the list of the headers to copy from the authentication server to the request.
|
|
|
|
|
|
|
|
### tls
|
|
|
|
|
|
|
|
The `tls` option is the tls configuration from Traefik to the authentication server.
|