Dynamic Policies Powered by JavaScript
Write custom access rules in JavaScript to enforce any scenario—without rebuilding your authorization logic. Perfect for advanced, one-off, or calculated permission needs.
How JavaScript-Based Policies Work in Keymate
Keymate lets you define advanced access logic directly in JavaScript. You can reference user attributes, tokens, request parameters, and apply logic using the familiar grant() / deny() methods supported by Keycloak's native JS Policy engine. With built-in simulation and audit tools, these dynamic policies become maintainable, testable, and safer.
JavaScript Policy Evaluation Flow
Keymate lets you define advanced access logic directly in JavaScript. You can reference user attributes, tokens, request parameters, and apply logic using the familiar grant()
/ deny()
methods supported by Keycloak's native JS Policy engine.
With built-in simulation and audit tools, these dynamic policies become maintainable, testable, and safer.
Example: Example JS policy: if (user.department === "Sales" && resource.type === "Proposal") { grant(); } else if (context.time >= "18:00") { deny("No access after working hours"); } else { deny(); }
Key Components:
What Makes Dynamic Policies in Keymate Unique
JavaScript Editor with Syntax Highlighting
Write logic directly with auto-complete, validation, and grant/deny guidance.
Full Token + Context Access
Access token claims, session context, and request parameters in script.
Sandboxed Evaluation
Scripts are isolated and validated for secure, deterministic execution.
"Why Denied?" Debugging
Trace which branch of your JS logic was executed and why.
Audit and Versioning Support
Track changes in JS scripts and revert if needed.
Environment-Specific Logic
Write logic per DEV/TEST/PROD with separation and labels.
Leverage the full power of JavaScript for fine-grained, dynamic access control.
Frequently Asked Questions
Understanding Keymate's JavaScript-Based Access Policies.
How to Use Dynamic Policies in Keymate
Leverage the flexibility of JavaScript to implement custom access control logic tailored to your exact needs.
Steps to Create and Enforce JavaScript-Based Policies
Choose "Dynamic" policy type in Admin Console
Select the JavaScript policy type when creating a new access policy in Keymate's management interface.
Use JS editor to write your logic
Utilize the built-in editor with syntax highlighting and auto-completion to script your policy using grant() and deny() methods.
Use "Test Policy" panel to simulate with token/context
Before deploying, test your JavaScript policy against various user profiles, token claims, and request contexts.
Tag policy to environment (DEV/TEST/PROD)
Assign your dynamic policy to specific environments to manage its lifecycle from development to production.
Enforce via SDK or Gateway plugin
Integrate with Keymate's SDKs or API Gateway plugins to enforce your JavaScript policies in real-time.
Explore the Dynamic Policy Editor
Experience the power of Keymate’s Dynamic Policy Editor to build, test, and manage your JavaScript policies.