Apologies for resurrecting this thread but we are in the same boat here. The way that different organizations handle authentication is often different and custom requirements drive orgs to build their own IAM stacks or lay out huge stacks of cash on profees.
The webhook integrations with before/after hooks could be similarly implemented with a plugin... perhaps preRequest and postResponse, meaning we can make custom changes prior to sending the request and after the response is received. Plugins would need to have the ability to manipulate the headers, session and other response objects for this to work.
One example which I brought up
here is the need for risk-based decisions during the authentication and recovery flows. To describe this use case in more detail, at the time of submitting some credentials, i.e. username and password, after the response is received from Kratos the plugin would check to see if the authentication was successful and depending on that would make an API call to a risk engine which would calculate if MFA is required based on many factors including things like geofencing, IP address, device details, etc.
It is true that it is hard to be sure plugins are secure, but that level of flexibility is needed for more widespread adoption of Kratos. The alternative could be that people choose not to use Kratos or (gasp) run an internal fork. Maybe that is OK and that is the direction for the product but it will prevent adoption in many cases.