nuts-foundation / data-viewer-py

A prototype ncurses CLI debugging tool for the nuts network in python (to be replaced with a go version later)
Apache License 2.0
1 stars 1 forks source link

Add support for JWT Bearer tokens #1

Open beardedfoo opened 1 year ago

beardedfoo commented 1 year ago

The API used by this project has a new authentication scheme (token_v2: https://nuts-node.readthedocs.io/en/stable/pages/integrating/api-authentication.html) which requires JWT bearer tokens to be passed in the "Authentication" header of HTTP requests.

The HTTP requests sent by this application shoud support optionally sending the correct authentication headers as generated from a configurable private key source.

There are a number of libraries available for generating these tokens (https://jwt.io/libraries).

Paul-kuria commented 1 year ago

https://gist.github.com/Paul-kuria/fee373f8275baee6032ead380fe000d5

Paul-kuria commented 1 year ago

parser: https://gist.github.com/Paul-kuria/4972c984301d2bdcdeaf89014dcf2154

Paul-kuria commented 1 year ago

The below code fills in all the payload parameters needed, and allows for entry of various keypairs and algorithms to create the jwt. There is a separate parser file used to input the public key, private key and algorithm.

https://gist.github.com/Paul-kuria/9b08ad0b9d0f3b76b8b2e46548ab03ba

Paul-kuria commented 1 year ago

https://gist.github.com/Paul-kuria/5f599b0e8955b7904323fb449f612e3d