
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@iad-os/jorah-policy-middleware
Advanced tools
npm i @iad-os/jorah-policy-middleware
import jorah from '@iad-os/jorah-policy-middleware';
//...
const config = {
url: 'http://opa:8181/v1/data',
dryRun: {
enabled: true,
header: 'x-authorizer',
},
};
const default = {
doPost: async (req, url, data, options) => {
return await axios.create().post(url, data, options);
},
onDecision: (req, res, next) => {
if (req.policyEvaluation.decision?.result?.allow) {
res.json(req.policyEvaluation);
next();
return;
}
next(new Error(`OPA-POLICY - FORBIDDEN`));
},
decisionPath: req => {
return `/${req.path.split('/')[1]}`;
},
toPolicyEvaluationRequest: (req, required) => ({
input: {
...required,
req: {
method: req.method,
params: req.params,
},
},
}),
};
export default jorah(config, default);
On express router middleware:
import express from 'express';
import jorah from './jorah';
const router = express.Router();
router.route('/').all(
// other middleware ...
jorah({
onDecision: (req, res, next) => {
res.json(req.policyEvaluation);
},
decisionPath: req =>
`${req.baseUrl}${reduce(req.params, (acc, param, name) => `${acc}/${name.replace('_id', '')}`, '')}`,
required: {
id: req => req.params.id
},
})
// other middleware ...
);
As express middleware:
import express from 'express';
import jorah from './jorah';
const expressApp = express()
// other middleware ...
.use(jorah({})); // in this way the middleware use a default configurations
FAQs
Open Policy Agent Middleware
We found that @iad-os/jorah-policy-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.