Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
doc: Update authorization token header in SQUAD docs
Browse files Browse the repository at this point in the history
Change the authorization token from "Auth-Token:" to "Authorization:
token" in SQUAD's documentation, to align with Django Rest Framework's
Authorization token format.

While both formats are currently supported by SQUAD, Django only treats
requests with the "Authorization: token" as authenticated, and will
treat requests made with "Auth-Token" as unauthenticated requests. This
can sometimes lead to incorrect behavior when using "Auth-Token".
For this reason documentation should be updated to change
"Authorization: token" to the preferred header for authentication.

Signed-off-by: Katie Worton <[email protected]>
  • Loading branch information
katieworton authored and bhcopeland committed Mar 13, 2024
1 parent 7b0faca commit 11ab164
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions doc/ci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Example (with test job definition as POST parameter)::

$ DEFINITION="$(cat /path/to/definition.txt)"
$ curl \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
--form backend=lava \
--form definition="$DEFINITION" \
https://squad.example.com/api/submitjob/my-group/my-project/x.y.z/my-ci-env

Example (with test job definition as file upload)::

$ curl \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
--form backend=lava \
--form definition=@/path/to/definition.txt \
https://squad.example.com/api/submitjob/my-group/my-project/x.y.z/my-ci-env
Expand Down Expand Up @@ -109,7 +109,7 @@ processing. The API is following:
Example (with test job definition as POST parameter)::

$ curl \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
--form backend=lava \
--form testjob_id=123456 \
https://squad.example.com/api/watchjob/my-group/my-project/x.y.z/my-ci-env
Expand Down
6 changes: 3 additions & 3 deletions doc/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ the format of the data files.
Example with test data as file uploads::

$ curl \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
--form tests=@/path/to/test-results.json \
--form metrics=@/path/to/metrics.json \
--form metadata=@/path/to/metadata.json \
Expand All @@ -96,7 +96,7 @@ Example with test data as file uploads::
Example with test data as regular ``POST`` parameters::

$ curl \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
--form tests='{"test1": "pass", "test2": "fail"}' \
--form metrics='{"metric1": 21, "metric2": 4}' \
--form metadata='{"foo": "bar", "baz": "qux", "job_id": 123}' \
Expand All @@ -118,7 +118,7 @@ Example with test data using Python's requests library:
metadata = json.dumps({"foo": "bar", "baz": "qux", "job_id": 123})
log = 'log text ...'
headers = {"Auth-Token": os.getenv('SQUAD_TOKEN')}
headers = {"Authorization": f"token {os.getenv('SQUAD_TOKEN')}"}
url = 'https://squad.example.com/api/submit/my-group/my-project/x.y.z/my-ci-env'
data = {"metadata": metadata, "log": log, "tests": tests_file}
Expand Down
2 changes: 1 addition & 1 deletion doc/lava_usecase.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ api for submitting a new test job::

wget https://validation.linaro.org/static/docs/v2/examples/test-jobs/qemu-pipeline-first-job.yaml
curl localhost:8000/api/submitjob/<group-slug>/<project-slug>/<build-version>/<env> \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
--form "backend=<backend-name>" \
--form "[email protected]"

Expand Down
4 changes: 2 additions & 2 deletions doc/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ by a freshly opened Github Pull Request::

$ curl \
-X POST \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
-d patch_source=your-github-patch-source \
-d patch_baseline=build-v1 \
-d patch_id=the_owner/the_repo/8223a534d7bf \
Expand Down Expand Up @@ -150,7 +150,7 @@ by a freshly created change::

$ curl \
-X POST \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
-d patch_source=your-gerrit-patch-source \
-d patch_baseline=build-v1 \
-d patch_id=change-id/patchset \
Expand Down
2 changes: 1 addition & 1 deletion doc/tuxsuite_usecase.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ to send to SQUAD's API for fetching::
...
curl localhost:8000/api/watchjob/<group-slug>/<project-slug>/<build-version>/<env> \
--header "Auth-Token: $SQUAD_TOKEN" \
--header "Authorization: token $SQUAD_TOKEN" \
--form "backend=tuxsuite.com" \
--form "job_id=BUILD:linaro@lkft#2843VDPeVhg4yaTkgTur0T3ykmq"

Expand Down

0 comments on commit 11ab164

Please sign in to comment.