Skip to content

Commit

Permalink
Api3 remove auth token (nightscout#6863)
Browse files Browse the repository at this point in the history
* APIv3: removing authorization by accessToken from codebase and adjusting tests

* APIv3: updating docs

---------

Co-authored-by: Petr Ondrůšek <petr.ondrusek@okin.eu>
Co-authored-by: Sulka Haro <sulka@sulka.net>
  • Loading branch information
3 people committed Feb 18, 2023
1 parent 89d7eb6 commit ac1a7d1
Show file tree
Hide file tree
Showing 18 changed files with 512 additions and 580 deletions.
3 changes: 1 addition & 2 deletions lib/api3/doc/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ The identity of the client is represented by the *subject* to whom the access le
For each security *subject*, the system automatically generates an *access token* that is difficult to guess since it is derived from the secret *API_SECRET*. The *access token* must be included in every secured API operation to decode the client's identity and determine its authorization level. In this way, it is then possible to resolve whether the client has the permission required by a particular API operation.


There are two ways to authorize API calls:
- use `token` query parameter to pass the *access token*, eg. `token=testreadab-76eaff2418bfb7e0`
There is only one way to authorize API calls:
- use so-called [JSON Web Tokens](https://jwt.io "JSON Web Tokens")
- at first let the `/api/v2/authorization/request` generates you a particular JWT, eg. `GET https://nsapiv3.herokuapp.com/api/v2/authorization/request/testreadab-76eaff2418bfb7e0`
- then, to each secure API operation attach a JWT token in the HTTP header, eg. `Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NUb2tlbiI6InRlc3RyZWFkYWItNzZlYWZmMjQxOGJmYjdlMCIsImlhdCI6MTU2NTAzOTczMSwiZXhwIjoxNTY1MDQzMzMxfQ.Y-OFtFJ-gZNJcnZfm9r4S7085Z7YKVPiaQxuMMnraVk` (until the JWT expires)
Expand Down
Loading

0 comments on commit ac1a7d1

Please sign in to comment.