This repository contains a collection of webhooks to provision users from Stych authentication service to Permit.io for Fine Grained Authorization.
The webhooks service is Node.js based and is written using the Express.js web framework.
To properly run the service, follow these steps.
To support multiple webhooks that provide different secrets, the project utilizes a custom header named
x-stytch-webhook-secret
that contains the environment variable name of the relevant secret. For example, if the header value isSYNC_USER_SECRET
, the webhook will look for theSYNC_USER_SECRET
environment variable to validate the webhook.
- Configure the relevant webhooks in Stytch to point to your server.
- Create a
.env
file, and copy the content from.env.template
to itcp .env.template .env
- Replace the
PERMIT_API_TOKEN
andSTYTCH_API_TOKEN
with the proper tokens from Permit and Stytch - Add the relevant webhook secrets to the
.env
file using the same names as the custom header values. - Install the dependencies
npm install
- Start the server
npm start
- (Optional) If you're running the project locally, you'll probably have to use a proxy service (like https://ngrok.com/) to expose it to Stytch.
You can now check the logs to see if the webhooks are being received and processed correctly. Stytch platform provide a test button to trigger the webhooks for testing.
The project is currently supported by the following flows to sync users (with roles) and tenants to Permit.
The project utilizes the query parameters of the webhooks to pass configuration for the flows.
This hook gets the user from Stych and creating/updating it in Permit.
https://{YOUR_SERVER_URL}/sync-users{optional_query_parameters}
*.user.create
- A new user has been created in Stytch*.user.update
- An existing user has been updated in Stytch
role_assignment = default | tenant
- if set will assign the role to a user. In case oftenant
the assignment will be done to the organization of the user.create_roles = true
- if set to true, it will create the roles if they do not exist.create_tenants = true
- if set to true, it will create the tenants if it does not exist.