website/docs: add proxy custom header docs

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-30 11:12:34 +01:00
parent b34f30f1dd
commit 45d1db8880
3 changed files with 44 additions and 2 deletions

View File

@ -0,0 +1,41 @@
---
title: Custom headers
---
The proxy can send custom headers to your upstream application. These can be configured in one of two ways:
- Group attributes; this allows for inheritance, but only allows static values
- Property mappings; this allows for dynamic values
## Group attributes
Edit the group or user you wish the header to be set for, and set these attributes:
```yaml
additionalHeaders:
X-My-Header: value
```
You can the add users to this group or override the field in users.
## Property Mappings
For dynamic Header values (for example, your application requires X-App-User to contain the username), property mappings can be used.
Create a new Scope mapping with a name and scope of your choice, and use an expression like this:
```python
return {
"ak_proxy": {
"user_attributes": {
"additionalHeaders": {
"X-App-User": request.user.username
}
}
}
}
```
After you've created this Scope mapping, make sure to edit the proxy provider and select the mapping.
As you can see by the similar structure, this just overrides any static attributes, so both of these methods can be combined.

View File

@ -18,7 +18,7 @@ module.exports = {
{ {
to: "docs/", to: "docs/",
activeBasePath: "docs", activeBasePath: "docs",
label: "Docs", label: "Documentation",
position: "left", position: "left",
}, },
{ {
@ -30,7 +30,7 @@ module.exports = {
{ {
to: "developer-docs/", to: "developer-docs/",
activeBasePath: "developer-docs", activeBasePath: "developer-docs",
label: "Developer Docs", label: "Developer",
position: "left", position: "left",
}, },
{ {

View File

@ -37,6 +37,7 @@ module.exports = {
label: "Proxy Provider", label: "Proxy Provider",
items: [ items: [
"providers/proxy/proxy", "providers/proxy/proxy",
"providers/proxy/custom_headers",
"providers/proxy/forward_auth", "providers/proxy/forward_auth",
], ],
}, },