Permit
Permit is an access control platform that provides fine-grained, real-time permission management using various models such as RBAC, ABAC, and ReBAC. It enables organizations to enforce dynamic policies across their applications, ensuring that only authorized users can access specific resources.
Overview
This package provides two Langchain tools for JWT validation and permission checking using Permit:
-
LangchainJWTValidationTool: Validates JWT tokens against a JWKS endpoint
-
LangchainPermissionsCheckTool: Checks user permissions using Permit
Setup
Set up the following environment variables:
PERMIT_API_KEY=your_permit_api_key
JWKS_URL=your_jwks_endpoint_url
PERMIT_PDP_URL=your_permit_pdp_url # Usually http://localhost:7766 for local development or your real deployment
Make sure your PDP (Policy Decision Point) is running at PERMIT_PDP_URL. See Permit docs for details on policy setup and how to launch the PDP container.
Credentials
PERMIT_API_KEY=
JWKS_URL=your_jwks_endpoint_url # or your deployed url
PERMIT_PDP_URL=your_pdp_url # or your deployed url
TEST_JWT_TOKEN= # for quick test purposes
It's also helpful (but not needed) to set up LangSmith for best-in-class observability:
Instantiation
JWT Validation Tool
The JWT Validation tool verifies JWT tokens against a JWKS (JSON Web Key Set) endpoint.
from langchain_permit.tools import LangchainJWTValidationTool
# Initialize the tool
jwt_validator = LangchainJWTValidationTool(
jwks_url=#your url endpoint
)