<@U04UQ68083H> can you give me an example of an af...
# ory-copilot
p
@chilly-king-10285 can you give me an example of an after verification hook for kratos?
b
A message from kapa.ai
Certainly! Here is an example of an "after verification" hook for Ory Kratos, which triggers a webhook after a user successfully verifies their account. This configuration can be added to your Kratos identity config under the verification flow:
Copy code
yaml selfservice:   flows:     verification:       enabled: true       ui_url: <http://127.0.0.1:3000/verification>       use: code       after:         hooks:           - hook: web_hook             config:               url: <http://host.docker.internal:8085/internal/user>               method: POST               body: file:///etc/config/kratos/segment_identity.jsonnet               response:                 ignore: false                 parse: false               auth:                 type: basic_auth                 config:                   user: mira_internal                   password: abc1234         default_browser_return_url: <http://127.0.0.1:3000/>
In this example, after a user completes the verification flow, Kratos will send a POST request to the specified URL with the provided authentication and body. You can customize the webhook URL, method, authentication, and body as needed for your integration. The
default_browser_return_url
specifies where the user is redirected after verification is complete [Docs > Kratos > Hooks](https://github.com/ory/kratos/issues/4024). For more details on available actions and how to configure hooks, see the official documentation [Docs > Kratos > Hooks](https://www.ory.sh/docs/kratos/hooks/configure-hooks#available-actions).
p
@chilly-king-10285 when I do that I get an error: "value must be "b2b_sso"" Kratos seems to need hooks in a specific order.
b
A message from kapa.ai
Based on the knowledge sources, there is no mention of an error message like "value must be 'b2b_sso'" in relation to configuring after verification hooks in Ory Kratos. However, there is clear documentation and community feedback that the order of hooks is important, especially when using the session hook (such as "Sign in after registration"). If the session hook is not the last in the list, subsequent hooks (like webhooks) may not be executed, which can cause unexpected behavior or errors in your flow [Docs > Troubleshooting](https://www.ory.sh/docs/troubleshooting/troubleshoot-actions) [Github Issue: "after registration" hook is not fired](https://github.com/ory/network/issues/361). To resolve issues with hooks not firing, ensure that: - You add hooks to each authentication method (e.g., password, oidc, webauthn) if you want them to trigger for those methods. - The session hook (if used) is always the last hook in the list for a given method. If you are seeing a specific error about "b2b_sso," this is not documented in the provided knowledge sources, and may be related to a misconfiguration or a feature not covered here. If you continue to encounter this error, please provide more context or check if your project is using features or plugins (like B2B SSO) that require special configuration. In summary: - Hooks must be ordered correctly, with session last. - Method-specific hooks override global hooks. - The error "value must be 'b2b_sso'" is not documented in the provided sources, so I cannot provide a definitive answer for that specific message. For more on hook ordering and troubleshooting, see the official documentation and community discussions [Docs > Troubleshooting](https://www.ory.sh/docs/troubleshooting/troubleshoot-actions) [Trigger precedence](https://www.ory.sh/docs/kratos/hooks/configure-hooks#trigger-precedence).
p
@chilly-king-10285 where can I find the things against which the configuration is validated?
b
A message from kapa.ai
Ory Kratos validates configuration—especially identity schemas—against JSON Schemas. The schemas and validation rules are defined in the Ory Kratos codebase and referenced in the documentation. For identity traits, Kratos uses [JSON Schema Draft 7](https://json-schema.org/learn/getting-started-step-by-step.html) to validate the structure and content of your configuration and identity schemas. The validation logic is enforced both for configuration files and for identity schemas you define for your users [Identity metadata & traits](https://www.ory.sh/docs/kratos/manage-identities/managing-users-identities-metadata#traits) [JSON schema and JSON paths](https://www.ory.sh/docs/kratos/reference/json-schema-json-paths). For the specific validation rules (such as which values are allowed for certain fields like
recovery.via
), Kratos uses internal JSON Schema extension files. For example, the error you encountered about
"value must be \"email\""
for
recovery.via
is enforced by the internal identity extension schema, which you can find referenced in the Kratos source code and discussed in community issues [Github Issue: Setting up identity schema with "Recovery via SMS" throwing error](https://github.com/ory/kratos/issues/4262). In summary, the things against which your configuration is validated are: - The JSON Schema Draft 7 standard for identity schemas. - Ory Kratos' own internal JSON Schema extensions and validation logic, which are referenced in the documentation and enforced by the service at runtime. For more details, see the documentation on [JSON schema and JSON paths](https://www.ory.sh/docs/kratos/reference/json-schema-json-paths) and [Identity metadata & traits](https://www.ory.sh/docs/kratos/manage-identities/managing-users-identities-metadata#traits).
p
@chilly-king-10285 can I see the "Ory Kratos' own internal JSON Schema extensions and validation logic".
b
A message from kapa.ai
The knowledge sources indicate that Ory Kratos uses internal JSON Schema extensions for validating identity schemas, and these are referenced in both the documentation and community discussions. However, the knowledge sources do not provide a direct link or the actual content of these internal JSON Schema extension files. They do mention that certain validation errors (such as
"value must be \"email\""
for
recovery.via
) are enforced by these internal schemas, and there are references to their existence in GitHub issues and documentation [Github Issue: Setting up identity schema with "Recovery via SMS" throwing error](https://github.com/ory/kratos/issues/4262). But, based on the provided knowledge sources, you cannot directly view the full content of "Ory Kratos' own internal JSON Schema extensions and validation logic" from the documentation or the links above. The sources only describe their effect and reference them conceptually, not their actual implementation or schema files. If you need to see the actual schema files, you would need to look into the Ory Kratos source code repository, which is not included in the knowledge sources provided here.
p
@chilly-king-10285 where is the source code for this validation?
b
A message from kapa.ai
I'm sorry, but the knowledge sources do not contain explicit information about the exact location of the source code for Ory Kratos' internal JSON Schema validation logic or its schema extension files. The documentation and GitHub issues reference the existence of these internal schemas and validation mechanisms, but do not provide direct links or file paths to the relevant source code or schema definitions [Github Issue: Setting up identity schema with "Recovery via SMS" throwing error](https://github.com/ory/kratos/issues/4262). If you need to review the actual validation logic or schema files, you would need to consult the Ory Kratos source code repository directly, which is not included in the provided knowledge sources.