<@U04UQ68083H> I am using the <webhook response ha...
# ory-copilot
e
@chilly-king-10285 I am using the webhook response handling capability in Kratos as I want to determine a user's Github organizations before letting them register. I was hoping that in the webhook I could make an API call to Github (using their OIDC Token), and respond with a 403 if the expected organization wasn't present. However (of course) the user isn't created in the Kratos database, so the identity of the user at that point is technically
00000000-0000-0000-0000-000000000000
and I can't contact Kratos in the webhook to get the OIDC token. Is there some way that I can either: • Give the webhook the ability to make Github API calls on behalf of the user (given they have completed the OIDC flow with Github as part of Kratos registration) • Get the user's Github organizations some other way (I am not getting the organizations in the
claims
)
b
A message from kapa.ai
Based on the information provided in the knowledge sources, I can offer some insights and potential solutions to your question about determining a user's GitHub organizations during registration using Kratos webhooks. However, it's important to note that the exact functionality you're looking for isn't directly addressed in the provided documents. 1. Webhook Response Handling: The [Webhook response handling](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#webhook-response-handling) documentation does mention that you can use webhooks to interrupt the flow or update the identity. However, it doesn't specifically address making API calls to external services like GitHub during this process. 2. Flow-interrupting webhooks: The [Integrate with Ory Cloud through webhooks](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#modify-identities) documentation mentions that you can use flow-interrupting webhooks to add extra validation during sign-up. This could potentially be used to check GitHub organizations, but it doesn't explicitly state how to access the GitHub API on behalf of the user. 3. Transient Payload: One potential solution is to use the
transient_payload
field, as mentioned in a [GitHub issue comment](https://github.com/ory/network/issues/187). This allows you to pass additional data along with the registration, which could include the GitHub token or other necessary information. The webhook could then use this data to make the GitHub API call. 4. Custom Data Mapping: Another approach could be to use custom data mapping for the GitHub social sign-in, as described in the [End-to-end GitHub example](https://www.ory.sh/docs/kratos/social-signin/data-mapping#end-to-end-github-example). You might be able to request additional scopes from GitHub to include organization information in the claims. Given these options, here are some potential approaches you could try: 1. Modify your GitHub social sign-in configuration to request the necessary scopes for accessing organization information. Then, use custom data mapping to include this information in the claims or metadata. 2. Use the
transient_payload
field to pass the GitHub token or other necessary information to your webhook. In the webhook, you can then use this information to make the GitHub API call. 3. If the above options don't work, you might need to consider a two-step registration process where you first collect the GitHub information and then use that in a subsequent registration step. It's important to note that the exact implementation details aren't provided in the available knowledge sources, and you might need to experiment or consult with Ory support for a more tailored solution to your specific use case.