Skip to content

Commit 387ea1e

Browse files
danimtbAbrilRBS
andauthored
Add docs for headers field in source_credentials.json and Auth source plugin (#4326)
* Add docs for headers field in source_credentials.json and Auth source plugin * Update reference/config_files/source_credentials.rst Co-authored-by: Abril Rincón Blanco <5364255+AbrilRBS@users.noreply.github.com> * review * wording * fix --------- Co-authored-by: Abril Rincón Blanco <5364255+AbrilRBS@users.noreply.github.com>
1 parent b108641 commit 387ea1e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

reference/config_files/source_credentials.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,26 @@ level:
7272
{
7373
"credentials": [
7474
{
75-
"url": "https://server/that/need/credentials",
75+
"url": "https://server/that/need/credentials",
7676
"token": "{{mytk}}"
7777
}
7878
]
7979
}
8080
81+
In some special cases, the server might need some specific custom headers. You can also specify them using a ``headers`` dictionary.
82+
83+
.. code-block:: json
84+
85+
{
86+
"credentials": [
87+
{
88+
"url": "https://server/that/need/credentials",
89+
"token": "mytoken",
90+
"headers": {"my-header-1": "my-value-1", "my-header-2": "my-value-2"}
91+
}
92+
]
93+
}
94+
8195
.. note::
8296

8397
**Best practices**

reference/extensions/authorization_plugins.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ Here we can see an example of a plugin implementation.
5959
elif url.startswith("https://my-private-token-sources.my-org/"):
6060
return {'token': 'my-secure-token'}
6161
62+
Additionally, returning a ``headers`` dictionary will add the contents as HTTP headers for the sources request,
63+
as some servers might need some specific custom headers:
64+
65+
.. code-block:: python
66+
67+
def auth_source_plugin(url, **kwargs):
68+
if url.startswith("https://my-private-token-sources-with-headers.my-org/"):
69+
return {'token': 'my-secure-token', 'headers': {'my-header-1': 'my-value-1'}}
70+
6271
6372
.. note::
6473

0 commit comments

Comments
 (0)