Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C# webhook server example #46

Merged
merged 2 commits into from
Mar 23, 2022
Merged

Conversation

alexheretic
Copy link
Contributor

@alexheretic alexheretic commented Mar 11, 2022

#47 for C#

C# webhook server example

A http server than can receive and verify signed TrueLayer webhooks.

Run

Run the server.

dotnet run

Send a valid webhook that was signed for path /hook/d7a2c49d-110a-4ed2-a07d-8fdb3ea6424b.

curl -iX POST -H "Content-Type: application/json" \
    -H "X-Tl-Webhook-Timestamp: 2022-03-11T14:00:33Z" \
    -H "Tl-Signature: eyJhbGciOiJFUzUxMiIsImtpZCI6IjFmYzBlNTlmLWIzMzUtNDdjYS05OWE5LTczNzQ5NTc1NmE1OCIsInRsX3ZlcnNpb24iOiIyIiwidGxfaGVhZGVycyI6IngtdGwtd2ViaG9vay10aW1lc3RhbXAiLCJqa3UiOiJodHRwczovL3dlYmhvb2tzLnRydWVsYXllci5jb20vLndlbGwta25vd24vandrcyJ9..AE_QsBRhnsMkcRzd42wvY1e2HruUhkOgjuZKktGH_WmbD7rBzoaEHUuF36IxyyvCbLajd3MBExNmzjbrOQsGaspwAI5DcGVMFLKUhB7ZzUlTP9up3eNUrdwWyyfBWDQb-qmEuLnrhFDJvgCXEqlV5OLrt-O7LaRAJ4f9KHsZLQ_j2vPC" \
    -d "{\"event_type\":\"payout_settled\",\"event_schema_version\":1,\"event_id\":\"8fb9fb4e-bb2b-400b-af64-59e5dde74bad\",\"event_body\":{\"transaction_id\":\"c34c8721-66a9-49f6-a229-284efcf88a02\",\"settled_at\":\"2022-03-11T14:00:32.933000Z\"}}" \
    http://localhost:5000/hook/d7a2c49d-110a-4ed2-a07d-8fdb3ea6424b

Modifying the X-Tl-Webhook-Timestamp header, the body or the path will cause the above signature to be invalid.

@alexheretic alexheretic requested a review from a team as a code owner March 11, 2022 15:33
@alexheretic alexheretic requested a review from a team March 11, 2022 15:33
@alexheretic alexheretic force-pushed the cs-webhook-server-example branch 3 times, most recently from f420203 to 25d19f8 Compare March 11, 2022 15:46
@alexheretic
Copy link
Contributor Author

It would be nice to have idiomatic HttpClient caching of the jwks here as we do want our clients to make use of caching the jwks.

@alexheretic alexheretic force-pushed the cs-webhook-server-example branch from 0af8e4c to 60451af Compare March 16, 2022 12:20
@alexheretic alexheretic force-pushed the cs-webhook-server-example branch from 60451af to 92b6057 Compare March 22, 2022 12:13
@alexheretic alexheretic merged commit e1c84cb into main Mar 23, 2022
@alexheretic alexheretic deleted the cs-webhook-server-example branch March 23, 2022 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants