WorkOS Action - Block Gmail Addresses

This Val Town application implements a WorkOS Action that blocks authentication and user registration for users with @gmail.com email addresses.

Getting started

  1. Get a copy of this app by clicking the Remix button in the top-right
  2. Set the required environment variables (see Configuration section below)
  3. Configure your WorkOS Dashboard to point to this action endpoint

Configuration

Set these environment variables in your Val Town settings:

  • WORKOS_API_KEY: Your WorkOS API key
  • WORKOS_ACTIONS_SECRET: The secret generated when you configure your action endpoint in the WorkOS Dashboard

How it works

  • The WorkOS Action endpoint is at /action in /backend/index.ts
  • When WorkOS calls this endpoint during authentication or registration flows, it validates the request signature and checks the user's email
  • If the email ends with @gmail.com, the action responds with "Deny" and blocks the operation
  • All other email addresses are allowed through

WorkOS Dashboard Setup

  1. Go to the WorkOS Dashboard
  2. Navigate to Actions
  3. Set your endpoint URL to: https://[your-val-name].web.val.run/action
  4. Enable the action and save your changes
  5. Copy the generated secret to your WORKOS_ACTIONS_SECRET environment variable

Testing

Use the WorkOS Dashboard's test feature to send test actions to your endpoint and verify it's working correctly.

Further resources