dyne / slangroom

Enhance zencode smart contracts with your slang
https://dyne.org/slangroom/
GNU Affero General Public License v3.0
5 stars 1 forks source link

Manage custom headers in GET/POST requests and respons with (neded in DPOP) #53

Closed andrea-dintino closed 10 months ago

andrea-dintino commented 10 months ago

DPOP (https://datatracker.ietf.org/doc/html/rfc9449) requires proof-of-possession to transit inside HTTP requests. DPOP requires an ecdsa signature on P-256 performed on a token and packaged (somehow) in the headers. The signature will occur in TEE (also to be managed via Slangroom?) ideally (!) in the same script as the GET/POST creation.

Examples:

  curl --request POST
  --url 'https://${yourOktaDomain}/oauth2/default/v1/token' \
  --header 'Accept: application/json' \
  --header 'DPoP: eyJ0eXAiOiJkcG9w.....H8-u9gaK2-oIj8ipg' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'grant_type=authorization_code' \
  --data 'redirect_uri=https://${yourOktaDomain}/app/oauth2' \
  --data 'code=XGa_U6toXP0Rvc.....SnHO6bxX0ikK1ss-nA' \
  --data 'code_verifier=k9raCwW87d_wYC.....zwTkqPqksT6E_s' \
  --data 'client_id=${clientId}'
curl -v -X GET \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: DPoP eyJraWQiOiJRVX.....wt7oSakPDUg' \
  --header 'DPoP: eyJ0eXAiOiJkcG9w.....H8-u9gaK2-oIj8ipg' \
  "https://resource.example.org"

Taken from: https://developer.okta.com/docs/guides/dpop/main/#build-the-request

Reference implementation: https://github.com/italia/eudi-wallet-it-python/tree/dev/pyeudiw/oauth2/dpop

denizenging commented 10 months ago

It already allows you to specify a string dictionary for headers of all supported http methods:

Given I connect to 'host' and send object 'dataToPost' and send headers 'stringDict" and do post

If this isn't something you're seeking for, please let me know.