A webhook authentication service that enables seamless integration between Hasura GraphQL Engine and Tapis authentication system. This service validates Tapis JWT tokens and transforms them into Hasura session variables for role-based access control.
- 🔐 JWT token validation using Tapis public key
- 🚀 Role-based access control mapping
- 📋 Session variable management
- ⚡ Performance optimization with caching
- 🛡️ TypeScript for type safety
- 🐳 Docker support
- 🧪 Comprehensive test suite
- Node.js (v18 or higher)
- npm or yarn
- Docker (optional)
- A running Hasura instance
- Tapis OAuth2 credentials
- Clone the repository:
git clone https://github.com/your-username/hasura-tapis-auth-webhook.git
cd hasura-tapis-auth-webhook
- Install dependencies:
npm install
- Build the project:
npm run build
Variable | Description | Required | Default |
---|---|---|---|
PORT | Server port | No | 3000 |
TAPIS_JWKS_URI | URI for Tapis JWKS endpoint | No | https://tacc.tapis.io/v3/tenants/tacc |
TAPIS_TOKEN_ISSUER | Expected token issuer | No | https://tacc.tapis.io/v3/tokens |
NODE_ENV | Environment mode | No | development |
Add these environment variables to your Hasura instance:
HASURA_GRAPHQL_AUTH_HOOK=http://your-webhook-url:3000/auth-webhook
HASURA_GRAPHQL_AUTH_HOOK_MODE=POST
npm run dev
- Start development server with hot reloadnpm run build
- Build for productionnpm start
- Start production servernpm test
- Run testsnpm run lint
- Run ESLintnpm run format
- Format code with Prettier
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage
Use the provided test script:
# Make script executable
chmod +x test-webhook.sh
# Run test (requires TACC_ACCESS_TOKEN environment variable)
./test-webhook.sh
docker build -t hasura-tapis-auth-webhook .
docker run -p 3000:3000 \
-e PORT=3000 \
-e TAPIS_JWKS_URI=https://tacc.tapis.io/v3/tenants/tacc \
-e TAPIS_TOKEN_ISSUER=https://tacc.tapis.io/v3/tokens \
hasura-tapis-auth-webhook
# Pull the image
docker pull ghcr.io/your-username/hasura-tapis-auth-webhook:latest
# Run the container
docker run -p 3000:3000 ghcr.io/your-username/hasura-tapis-auth-webhook:latest
POST /auth-webhook
The original request headers from Hasura will be forwarded.
{
"X-Hasura-Role": "user",
"X-Hasura-User-Id": "username",
"X-Hasura-Username": "username",
"X-Hasura-Tenant-Id": "tacc",
"Cache-Control": "max-age=600"
}
GET /health
Returns the service health status.
The project uses GitHub Actions for:
- Running tests
- Linting code
- Building Docker image
- Publishing to GitHub Container Registry
- Always use HTTPS in production
- Regularly update dependencies
- Monitor failed authentication attempts
- Keep authentication tokens secure
- Use appropriate CORS settings
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Write tests for new features
- Follow ESLint rules
- Format code using Prettier
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.