From fb5d6e78a8fb04bde7a7aa4a4a22f2421bfc6143 Mon Sep 17 00:00:00 2001 From: matteo-cristino Date: Mon, 24 Jun 2024 17:53:31 +0200 Subject: [PATCH] docs: add oauth plugin examples --- docs/examples/index.md | 1 + docs/examples/oauth/add_data.data | 6 +++ docs/examples/oauth/add_data.keys | 14 ++++++ docs/examples/oauth/add_data.zen | 6 +++ docs/examples/oauth/gen_access_token.data | 16 +++++++ docs/examples/oauth/gen_access_token.keys | 14 ++++++ docs/examples/oauth/gen_access_token.zen | 12 +++++ docs/examples/oauth/gen_auth_code.data | 8 ++++ docs/examples/oauth/gen_auth_code.keys | 14 ++++++ docs/examples/oauth/gen_auth_code.zen | 6 +++ docs/examples/oauth/gen_request_uri.data | 10 +++++ docs/examples/oauth/gen_request_uri.keys | 22 +++++++++ docs/examples/oauth/gen_request_uri.zen | 6 +++ docs/examples/oauth/get_auth_details.data | 3 ++ docs/examples/oauth/get_auth_details.keys | 5 +++ docs/examples/oauth/get_auth_details.zen | 6 +++ docs/examples/oauth/index.md | 49 +++++++++++++++++++++ docs/examples/oauth/ver_request_params.data | 9 ++++ docs/examples/oauth/ver_request_params.keys | 14 ++++++ docs/examples/oauth/ver_request_params.zen | 15 +++++++ 20 files changed, 236 insertions(+) create mode 100644 docs/examples/oauth/add_data.data create mode 100644 docs/examples/oauth/add_data.keys create mode 100644 docs/examples/oauth/add_data.zen create mode 100644 docs/examples/oauth/gen_access_token.data create mode 100644 docs/examples/oauth/gen_access_token.keys create mode 100644 docs/examples/oauth/gen_access_token.zen create mode 100644 docs/examples/oauth/gen_auth_code.data create mode 100644 docs/examples/oauth/gen_auth_code.keys create mode 100644 docs/examples/oauth/gen_auth_code.zen create mode 100644 docs/examples/oauth/gen_request_uri.data create mode 100644 docs/examples/oauth/gen_request_uri.keys create mode 100644 docs/examples/oauth/gen_request_uri.zen create mode 100644 docs/examples/oauth/get_auth_details.data create mode 100644 docs/examples/oauth/get_auth_details.keys create mode 100644 docs/examples/oauth/get_auth_details.zen create mode 100644 docs/examples/oauth/index.md create mode 100644 docs/examples/oauth/ver_request_params.data create mode 100644 docs/examples/oauth/ver_request_params.keys create mode 100644 docs/examples/oauth/ver_request_params.zen diff --git a/docs/examples/index.md b/docs/examples/index.md index 97ed13ac..9ee87b1a 100644 --- a/docs/examples/index.md +++ b/docs/examples/index.md @@ -13,3 +13,4 @@ SPDX-License-Identifier: CC-BY-NC-SA-4.0 + diff --git a/docs/examples/oauth/add_data.data b/docs/examples/oauth/add_data.data new file mode 100644 index 00000000..0aea93ad --- /dev/null +++ b/docs/examples/oauth/add_data.data @@ -0,0 +1,6 @@ +{ + "request_uri": "urn:ietf:params:oauth:request_uri:1719239545ed9f269e652d207b90dec394b87225c92346023b", + "data": { + "email": "email@example.com" + } +} diff --git a/docs/examples/oauth/add_data.keys b/docs/examples/oauth/add_data.keys new file mode 100644 index 00000000..7d382aaf --- /dev/null +++ b/docs/examples/oauth/add_data.keys @@ -0,0 +1,14 @@ +{ + "server_data": { + "jwk": { + "kty": "EC", + "crv": "P-256", + "alg": "ES256", + "x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74", + "y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI", + "d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk" + }, + "url": "https://valid.issuer.url", + "authentication_url": "https://did.dyne.org/dids/" + } +} diff --git a/docs/examples/oauth/add_data.zen b/docs/examples/oauth/add_data.zen new file mode 100644 index 00000000..a162e54f --- /dev/null +++ b/docs/examples/oauth/add_data.zen @@ -0,0 +1,6 @@ +Rule unknown ignore + +Given I send request_uri 'request_uri' and send data 'data' and send server_data 'server' and add data to authorization details and output into 'result' + +Given I have a 'string array' named 'result' +Then print the 'result' diff --git a/docs/examples/oauth/gen_access_token.data b/docs/examples/oauth/gen_access_token.data new file mode 100644 index 00000000..5d588406 --- /dev/null +++ b/docs/examples/oauth/gen_access_token.data @@ -0,0 +1,16 @@ +{ + "json_body": { + "grant_type": "authorization_code", + "client_id": "did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5", + "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", + "redirect_uri": "https://Wallet.example.org/cb", + "code": "eyJhbGciOiJFUzI1NiIsImp3ayI6eyJrdHkiOiJFQyIsIngiOiJ0R3hhcWJYR3JsNm92VC11NXNWMU1vUFRESG5ZTEtZbkNpZzM0NW5zSmc4IiwieSI6IlFOT3RBRzd4Sm52cHlGS2lGdmJJdFBxaVBiN2VZSVMtQlRvU0YwaHM3NTgiLCJjcnYiOiJQLTI1NiJ9fQ.eyJzdWIiOiI1NDJiYWNjODAyMDUxZTdhYjBjMWZhNDAxZjAwYzhjNWJjN2Y0NzVhIiwiaWF0IjoxNzE5MjQxMTYzLCJpc3MiOiJodHRwczovL2Rldi5hdXRoei1zZXJ2ZXIxLmZvcmtib21iLmV1L2F1dGh6X3NlcnZlciIsImF1ZCI6ImRpZDpkeW5lOnNhbmRib3guc2lnbnJvb206NEtFeW1XZ0xEVWYxTE5ja2V4WTk2ZGZLejV2SDc5ZGlEZWtnTE1SOUZXcEgiLCJleHAiOjE3MTkyNDQ3NjJ9.1OhQ5FKXuh_QWxm4XMufNqFS2Zkql7bmBzfMuT8GzVEil3HzYM7dAwUo5Zl9shu-w7bEGlKkOIhXssVrMeMlXg" + }, + "request": { + "headers": { + "content-length": 42, + "Content-Type": "application/x-www-form-urlencoded", + "DPoP": "eyJhbGciOiJFUzI1NiIsImp3ayI6eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6InpKLTR1d0VWVlYxQW9GcW1yZVlzUlh1SjhGbzVHRVVUeTZ0aklBdjdUcFkiLCJ5IjoiVm9YdmEzVEpHc0o5bjlZVzV3MGplMHp6U2hmYnN3QWd6SHI1TEZCSDNsZyJ9LCJ0eXAiOiJkcG9wK2p3dCJ9.eyJodG0iOiJQT1NUIiwiaHR1IjoiaHR0cHM6Ly9kZXYuYXV0aHotc2VydmVyMS5mb3JrYm9tYi5ldS9hdXRoel9zZXJ2ZXIvdG9rZW4iLCJpYXQiOjE3MTkyNDEzMjYsImp0aSI6IkFad0VwZ2tOTlhrbllWT1JZbjNYNW9HVW1iTVp3V3d1UF9xSDNnOFRjbHcifQ.X2sO6h3GUcTu0h_qNyOsXEB2Z3qzPUd1azOJIeMmfH4zIk-Hd8sHm1RG2RaxZ3n22qSDbKjBap2G9U3Kjw5gLA" + } + } +} diff --git a/docs/examples/oauth/gen_access_token.keys b/docs/examples/oauth/gen_access_token.keys new file mode 100644 index 00000000..7d382aaf --- /dev/null +++ b/docs/examples/oauth/gen_access_token.keys @@ -0,0 +1,14 @@ +{ + "server_data": { + "jwk": { + "kty": "EC", + "crv": "P-256", + "alg": "ES256", + "x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74", + "y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI", + "d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk" + }, + "url": "https://valid.issuer.url", + "authentication_url": "https://did.dyne.org/dids/" + } +} diff --git a/docs/examples/oauth/gen_access_token.zen b/docs/examples/oauth/gen_access_token.zen new file mode 100644 index 00000000..b70640cc --- /dev/null +++ b/docs/examples/oauth/gen_access_token.zen @@ -0,0 +1,12 @@ +Rule unknown ignore +Scenario 'http': url encode + +Given I have a 'string dictionary' named 'json_body' +Given I have a 'string dictionary' named 'request' + +When I create the http get parameters from 'json_body' using percent encoding +When I move 'json_body' to 'body' in 'request' + +Then print the 'request' + +Then I send request 'request' and send server_data 'server_data' and generate access token and output into 'result' diff --git a/docs/examples/oauth/gen_auth_code.data b/docs/examples/oauth/gen_auth_code.data new file mode 100644 index 00000000..d0059add --- /dev/null +++ b/docs/examples/oauth/gen_auth_code.data @@ -0,0 +1,8 @@ +{ + "request": { + "body": "client_id=did%3Adyne%3Asandbox%2Egenericissuer%3A6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5&request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3A1719239545ed9f269e652d207b90dec394b87225c92346023b", + "headers": { + "Authorization": "" + } + } +} diff --git a/docs/examples/oauth/gen_auth_code.keys b/docs/examples/oauth/gen_auth_code.keys new file mode 100644 index 00000000..7d382aaf --- /dev/null +++ b/docs/examples/oauth/gen_auth_code.keys @@ -0,0 +1,14 @@ +{ + "server_data": { + "jwk": { + "kty": "EC", + "crv": "P-256", + "alg": "ES256", + "x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74", + "y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI", + "d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk" + }, + "url": "https://valid.issuer.url", + "authentication_url": "https://did.dyne.org/dids/" + } +} diff --git a/docs/examples/oauth/gen_auth_code.zen b/docs/examples/oauth/gen_auth_code.zen new file mode 100644 index 00000000..e272d9a3 --- /dev/null +++ b/docs/examples/oauth/gen_auth_code.zen @@ -0,0 +1,6 @@ +Rule unknown ignore + +Given I send request 'request' and send server_data 'server' and generate authorization code and output into 'result' + +Given I have a 'string dictionary' named 'result' +Then print the 'result' diff --git a/docs/examples/oauth/gen_request_uri.data b/docs/examples/oauth/gen_request_uri.data new file mode 100644 index 00000000..3e454383 --- /dev/null +++ b/docs/examples/oauth/gen_request_uri.data @@ -0,0 +1,10 @@ +{ + "client": { + "id": "did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5", + "clientSecret": "eyJhbGciOiJFUzI1NiJ9.eyJzdWIiOiJwaXBwbyJ9.hiVPL2JTdmcZY7Vcso95KUBEzcTGvmvQ7wlwkCo0G74Unpzny2drvLsu-HzHWyckKbRjwWox-V5gqqKeka8kEQ", + "grants": ["authorization_code"], + "redirectUris": ["https://Wallet.example.org/cb"], + "scope": ["Auth1"], + "resource": "http://issuer1.zenswarm.forkbomb.eu/credential_issuer" + } +} diff --git a/docs/examples/oauth/gen_request_uri.keys b/docs/examples/oauth/gen_request_uri.keys new file mode 100644 index 00000000..a4a08f2b --- /dev/null +++ b/docs/examples/oauth/gen_request_uri.keys @@ -0,0 +1,22 @@ +{ + "server_data": { + "jwk": { + "kty": "EC", + "crv": "P-256", + "alg": "ES256", + "x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74", + "y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI", + "d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk" + }, + "url": "https://valid.issuer.url", + "authentication_url": "https://did.dyne.org/dids/" + }, + "expires_in": 500, + "request": { + "body": "response_type=code&client_id=did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5&state=xyz&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&code_challenge_method=S256&redirect_uri=https%3A%2F%2FWallet.example.org%2Fcb&authorization_details=%5B%7B%22type%22%3A%20%22openid_credential%22%2C%20%22credential_configuration_id%22%3A%20%22Auth1%22%2C%22locations%22%3A%20%5B%22http%3A%2F%2Fissuer1.zenswarm.forkbomb.eu%3A3100%2Fcredential_issuer%2F%22%5D%7D%5D", + "headers": { + "Authorization": "" + } + } +} + diff --git a/docs/examples/oauth/gen_request_uri.zen b/docs/examples/oauth/gen_request_uri.zen new file mode 100644 index 00000000..9b05d1ca --- /dev/null +++ b/docs/examples/oauth/gen_request_uri.zen @@ -0,0 +1,6 @@ +Rule unknown ignore + +Given I send request 'request' and send client 'client' and send server_data 'server_data' and send expires_in 'expires_in' and generate request uri and output into 'result' + +Given I have a 'string dictionary' named 'result' +Then print the 'result' diff --git a/docs/examples/oauth/get_auth_details.data b/docs/examples/oauth/get_auth_details.data new file mode 100644 index 00000000..3ab49984 --- /dev/null +++ b/docs/examples/oauth/get_auth_details.data @@ -0,0 +1,3 @@ +{ + "token": "eyJhbGciOiJFUzI1NiIsImp3ayI6eyJrdHkiOiJFQyIsIngiOiJ0R3hhcWJYR3JsNm92VC11NXNWMU1vUFRESG5ZTEtZbkNpZzM0NW5zSmc4IiwieSI6IlFOT3RBRzd4Sm52cHlGS2lGdmJJdFBxaVBiN2VZSVMtQlRvU0YwaHM3NTgiLCJjcnYiOiJQLTI1NiJ9fQ.eyJzdWIiOiJjYzA3N2Y4MTcwMWU3NDIxNTQ5ZmU0MjBiNDFiNTUxMjVlZDljNmZlIiwiaWF0IjoxNzE5MjQxMzI3LCJpc3MiOiJodHRwczovL2Rldi5hdXRoei1zZXJ2ZXIxLmZvcmtib21iLmV1L2F1dGh6X3NlcnZlciIsImF1ZCI6ImRpZDpkeW5lOnNhbmRib3guc2lnbnJvb206NEtFeW1XZ0xEVWYxTE5ja2V4WTk2ZGZLejV2SDc5ZGlEZWtnTE1SOUZXcEgiLCJleHAiOjE3MTkyNDQ5Mjd9.xLWyO9DkLnSU-9w_4kzmI-znQAwlYJnBbZXpKqmHNpwnFwJUdK26hmVgIQSy2HcHujKyaXX6unjmFe1P5HyK9A" +} diff --git a/docs/examples/oauth/get_auth_details.keys b/docs/examples/oauth/get_auth_details.keys new file mode 100644 index 00000000..39d1d8c7 --- /dev/null +++ b/docs/examples/oauth/get_auth_details.keys @@ -0,0 +1,5 @@ +{ + "server": { + "url": "https://valid.issuer.url" + } +} diff --git a/docs/examples/oauth/get_auth_details.zen b/docs/examples/oauth/get_auth_details.zen new file mode 100644 index 00000000..f9132dfe --- /dev/null +++ b/docs/examples/oauth/get_auth_details.zen @@ -0,0 +1,6 @@ +Rule unknown ignore + +Given I send token 'token' and send server_data 'server' and get authorization details from token and output into 'result' + +Given I have a 'string array' named 'result' +Then print data diff --git a/docs/examples/oauth/index.md b/docs/examples/oauth/index.md new file mode 100644 index 00000000..d50e9912 --- /dev/null +++ b/docs/examples/oauth/index.md @@ -0,0 +1,49 @@ + + +## oauth plugin examples + +### generate request uri +::: code-group +<<< @/examples/oauth/gen_request_uri.zen{3 gherkin:line-numbers} +<<< @/examples/oauth/gen_request_uri.data{json} +<<< @/examples/oauth/gen_request_uri.keys{json} +::: + +### verify request parameters +::: code-group +<<< @/examples/oauth/ver_request_params.zen{15 gherkin:line-numbers} +<<< @/examples/oauth/ver_request_params.data{json} +<<< @/examples/oauth/ver_request_params.keys{json} +::: + +### add data to authorization details +::: code-group +<<< @/examples/oauth/add_data.zen{3 gherkin:line-numbers} +<<< @/examples/oauth/add_data.data{json} +<<< @/examples/oauth/add_data.keys{json} +::: + +### generate authorization code +::: code-group +<<< @/examples/oauth/gen_auth_code.zen{3 gherkin:line-numbers} +<<< @/examples/oauth/gen_auth_code.data{json} +<<< @/examples/oauth/gen_auth_code.keys{json} +::: + +### generate access token +::: code-group +<<< @/examples/oauth/gen_access_token.zen{12 gherkin:line-numbers} +<<< @/examples/oauth/gen_access_token.data{json} +<<< @/examples/oauth/gen_access_token.keys{json} +::: + +### get authorization details +::: code-group +<<< @/examples/oauth/get_auth_details.zen{3 gherkin:line-numbers} +<<< @/examples/oauth/get_auth_details.data{json} +<<< @/examples/oauth/get_auth_details.keys{json} +::: diff --git a/docs/examples/oauth/ver_request_params.data b/docs/examples/oauth/ver_request_params.data new file mode 100644 index 00000000..65f6ce51 --- /dev/null +++ b/docs/examples/oauth/ver_request_params.data @@ -0,0 +1,9 @@ +{ + "client_id": "did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5", + "request_uri": "urn:ietf:params:oauth:request_uri:1719239545ed9f269e652d207b90dec394b87225c92346023b", + "request": { + "headers": { + "Authorization": "" + } + } +} diff --git a/docs/examples/oauth/ver_request_params.keys b/docs/examples/oauth/ver_request_params.keys new file mode 100644 index 00000000..7d382aaf --- /dev/null +++ b/docs/examples/oauth/ver_request_params.keys @@ -0,0 +1,14 @@ +{ + "server_data": { + "jwk": { + "kty": "EC", + "crv": "P-256", + "alg": "ES256", + "x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74", + "y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI", + "d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk" + }, + "url": "https://valid.issuer.url", + "authentication_url": "https://did.dyne.org/dids/" + } +} diff --git a/docs/examples/oauth/ver_request_params.zen b/docs/examples/oauth/ver_request_params.zen new file mode 100644 index 00000000..daf9c851 --- /dev/null +++ b/docs/examples/oauth/ver_request_params.zen @@ -0,0 +1,15 @@ +Rule unknown ignore + +Given I have a 'string' named 'client_id' +Given I have a 'string' named 'request_uri' +Given I have a 'string dictionary' named 'request' + +When I set 'body' to 'client_id=' as 'string' +When I append the 'client_id' to 'body' +When I append the string '&request_uri=' to 'body' +When I append the 'request_uri' to 'body' +When I move 'body' in 'request' + +Then print the 'request' + +Then I send request 'request' and send server_data 'server_data' and verify request parameters