WEBHOOKS-121 Generate JWT token in ThreadLocalContext of webhook trigger
Michael Heemskerk
Branch: issue/WEBHOOKS-121-dispatch-thread-context
Branch: master
Declined
Declined pull request
The PR has stalled and the code has moved on
Closed by: Michael Heemskerk·2017-02-15
Webhooks are dispatched on a separate thread and the JWT tokens that are generated to sign these callbacks are generated on the dispatcher thread. atlassian-jwt has a pluggable mechanism that allows plugins and the host app to inject custom JWT claims into the token when it's generated.
These JwtClaimWriters may depend on the request context that triggered the webhook, i.e. the current user.
SAL's ThreadLocalContextManager is used to capture the context when the PublishTask is created and to restore the context on the dispatcher thread when the JWT token is generated and the webhook is sent.