-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Simple Authentication for webhook related event sources. Closes #…
- Loading branch information
Showing
11 changed files
with
503 additions
and
311 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Webhook Authentication | ||
|
||
![alpha](assets/alpha.svg) | ||
|
||
> v1.0 and after | ||
For `webhook` event source, if you want to get your endpoint protected from | ||
unauthorized accessing, you can specify `authSecret` to the spec, which is a K8s | ||
secret key selector. | ||
|
||
This simple authentication approach also works for `webhook` extended event | ||
sources, if that event source does not have a built in authenticator. | ||
|
||
Firstly, create a k8s secret containing your token. | ||
|
||
```sh | ||
echo -n 'af3qqs321f2ddwf1e2e67dfda3fs' > ./token.txt | ||
|
||
kubectl create secret generic my-webhook-token --from-file=my-token=./token.txt | ||
``` | ||
|
||
Then add `authSecret` to your `webhook` EventSource. | ||
|
||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: EventSource | ||
metadata: | ||
name: webhook | ||
spec: | ||
webhook: | ||
example: | ||
port: "12000" | ||
endpoint: /example | ||
method: POST | ||
authSecret: | ||
name: my-webhook-token | ||
key: my-token | ||
``` | ||
Now you can authenticate your webhook endpoint with the configured token. | ||
```sh | ||
TOKEN="Bearer af3qqs321f2ddwf1e2e67dfda3fs" | ||
|
||
curl -X POST -H "Authorization: $TOKEN" -d "{your data}" http://xxxxx:12000/example | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.