Session ID is nil in post login password webhook
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
Ory Network Project
No response
Describe the bug
In post login webhook scenario, there is a case where session ID is passed as nil UUID (00000000-0000-0000-0000-000000000000). This issue is similar to the #3340.
This happens because webhook is launched before the session is persisted, thus not guaranteeing that session ID will be filled at the sending time.
My thoughts that this issue could be fixed by adding and exposing additional method "Interruptible" on Webhook struct and iterating through post login hooks two time. Once before persisting session with interruptible hooks and once after session was persisted for non interruptible hooks.
Would you consider a contribution for fixing this issue or rather you would focus on #3352 instead?
Reproducing the bug
- checkout repository
- adjust contrib/quickstart/kratos/email-password/kratos.yml with relevant configuration
- Adjust quickstart.yml with request basket service (or use any other request dumper)
rb:
image: darklynx/request-baskets
ports:
- "55555:55555"
networks:
- intranet- open localhost:55555 and create bucket with name
dump - try login and logout few times in a row.
Relevant log output
No response
Relevant configuration
login:
ui_url: http://127.0.0.1:4455/login
lifespan: 10m
after:
password:
hooks:
- hook: web_hook # To use webhooks, you must set 'hook' to 'web_hook'
config:
url: http://rb:55555/dump # Webhook URL.
method: POST # HTTP method used to send request to the webhook URL.
body: base64://ZnVuY3Rpb24oY3R4KSB7IHNlc3Npb25JZDogY3R4LnNlc3Npb24uaWQgfQ== # Encoded Jsonnet template used to render payload.
response:
ignore: true # Defines if the webhook response should be ignored and run async. Boolean. OPTIONAL
parse: false # Defines if the webhook response should be parsed and interpreted. Boolean. OPTIONAL
auth:
type: api_key
config:
name: Authorization
value: "some-key-123"
in: header # alternatively "cookie"Version
master
On which operating system are you observing this issue?
Linux
In which environment are you deploying?
Docker Compose
Additional Context
No response
Source: ory/kratos