From 11ab1644b24c401cfbe4c452e61e0cf2d3502e18 Mon Sep 17 00:00:00 2001 From: Katie Worton Date: Thu, 7 Mar 2024 13:19:14 +0000 Subject: [PATCH] doc: Update authorization token header in SQUAD docs 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 --- doc/ci.rst | 6 +++--- doc/intro.rst | 6 +++--- doc/lava_usecase.rst | 2 +- doc/plugins.rst | 4 ++-- doc/tuxsuite_usecase.rst | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/ci.rst b/doc/ci.rst index 19ea616b6..ec4eef365 100644 --- a/doc/ci.rst +++ b/doc/ci.rst @@ -61,7 +61,7 @@ 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 @@ -69,7 +69,7 @@ Example (with test job definition as POST parameter):: 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 @@ -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 diff --git a/doc/intro.rst b/doc/intro.rst index 154db7708..692ddba9c 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -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 \ @@ -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}' \ @@ -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} diff --git a/doc/lava_usecase.rst b/doc/lava_usecase.rst index bda6fc24b..007fe84ad 100644 --- a/doc/lava_usecase.rst +++ b/doc/lava_usecase.rst @@ -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//// \ - --header "Auth-Token: $SQUAD_TOKEN" \ + --header "Authorization: token $SQUAD_TOKEN" \ --form "backend=" \ --form "definition=@qemu-pipeline-first-job.yaml" diff --git a/doc/plugins.rst b/doc/plugins.rst index a6ab8df19..b1cf6d886 100644 --- a/doc/plugins.rst +++ b/doc/plugins.rst @@ -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 \ @@ -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 \ diff --git a/doc/tuxsuite_usecase.rst b/doc/tuxsuite_usecase.rst index 78708e8f3..25a856729 100644 --- a/doc/tuxsuite_usecase.rst +++ b/doc/tuxsuite_usecase.rst @@ -63,7 +63,7 @@ to send to SQUAD's API for fetching:: ... curl localhost:8000/api/watchjob//// \ - --header "Auth-Token: $SQUAD_TOKEN" \ + --header "Authorization: token $SQUAD_TOKEN" \ --form "backend=tuxsuite.com" \ --form "job_id=BUILD:linaro@lkft#2843VDPeVhg4yaTkgTur0T3ykmq"