Skip to content

Commit 33c23ef

Browse files
committed
Reviewed the quickstart and improved the READMEs. Updated the token binding check to make the pay claim mandatory to be in line with the latest changes in Approov.
Signed-off-by: Exadra37 <exadra37@gmail.com>
1 parent 9b59c00 commit 33c23ef

File tree

4 files changed

+48
-10
lines changed

4 files changed

+48
-10
lines changed

docs/APPROOV_TOKEN_BINDING_QUICKSTART.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,10 @@ class Approov
194194
* @return bool
195195
*/
196196
private function verifyApproovTokenBinding(HeaderBag $headers, \stdClass $approov_token_claims): bool {
197-
// Note that the `pay` claim will, under normal circumstances, be present,
198-
// but if the Approov failover system is enabled, then no claim will be
199-
// present, and in this case you want to return true, otherwise you will not
200-
// be able to benefit from the redundancy afforded by the failover system.
201197
if (empty($approov_token_claims->pay)) {
202198
// You may want to add some logging here
203199
// \Log::debug("MISSIG APPROOV TOKEN BINDING CLAIM");
204-
return true;
200+
return false;
205201
}
206202

207203
// We use the Authorization token, but feel free to use another header in

src/approov-protected-server/token-binding-check/hello/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ php artisan serve --port 8002
5858

5959
> **NOTE:** If running the server inside a docker container add `--host 0.0.0.0.`, otherwise the Laravel server will not answer requests from outside the container, like the ones you may want to do from cURL or Postman to test the API.
6060
61+
Next, you can test that it works with:
62+
63+
```bash
64+
curl -iX GET 'http://localhost:8002'
65+
```
66+
67+
The response will be a `401` unauthorized request:
68+
69+
```text
70+
HTTP/1.1 401 Unauthorized
71+
Host: localhost:8002
72+
Date: Wed, 23 Mar 2022 12:24:03 GMT
73+
Connection: close
74+
X-Powered-By: PHP/8.1.4
75+
Cache-Control: no-cache, private
76+
Date: Wed, 23 Mar 2022 12:24:03 GMT
77+
Content-Type: application/json
78+
79+
{}
80+
```
81+
82+
The reason you got a `401` is because no Approoov token isn't provided in the headers of the request.
83+
6184
Finally, you can test that the Approov integration example works as expected with this [Postman collection](/README.md#testing-with-postman) or with some cURL requests [examples](/README.md#testing-with-curl).
6285

6386

src/approov-protected-server/token-binding-check/hello/app/Http/Middleware/Approov.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,10 @@ private function verifyApproovToken(HeaderBag $headers): ?\stdClass {
8989
* @return bool
9090
*/
9191
private function verifyApproovTokenBinding(HeaderBag $headers, \stdClass $approov_token_claims): bool {
92-
// Note that the `pay` claim will, under normal circumstances, be present,
93-
// but if the Approov failover system is enabled, then no claim will be
94-
// present, and in this case you want to return true, otherwise you will not
95-
// be able to benefit from the redundancy afforded by the failover system.
9692
if (empty($approov_token_claims->pay)) {
9793
// You may want to add some logging here
9894
// \Log::debug("MISSIG APPROOV TOKEN BINDING CLAIM");
99-
return true;
95+
return false;
10096
}
10197

10298
// We use the Authorization token, but feel free to use another header in

src/approov-protected-server/token-check/hello/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,29 @@ php artisan serve --port 8002
5757

5858
> **NOTE:** If running the server inside a docker container add `--host 0.0.0.0.`, otherwise the Laravel server will not answer requests from outside the container, like the ones you may want to do from cURL or Postman to test the API.
5959
60+
Next, you can test that it works with:
61+
62+
```bash
63+
curl -iX GET 'http://localhost:8002'
64+
```
65+
66+
The response will be a `401` unauthorized request:
67+
68+
```text
69+
HTTP/1.1 401 Unauthorized
70+
Host: localhost:8002
71+
Date: Wed, 23 Mar 2022 12:24:03 GMT
72+
Connection: close
73+
X-Powered-By: PHP/8.1.4
74+
Cache-Control: no-cache, private
75+
Date: Wed, 23 Mar 2022 12:24:03 GMT
76+
Content-Type: application/json
77+
78+
{}
79+
```
80+
81+
The reason you got a `401` is because no Approoov token isn't provided in the headers of the request.
82+
6083
Finally, you can test that the Approov integration example works as expected with this [Postman collection](/README.md#testing-with-postman) or with some cURL requests [examples](/README.md#testing-with-curl).
6184

6285
[TOC](#toc---table-of-contents)

0 commit comments

Comments
 (0)