Deployments will differ in production. The policy itself just needs the configs, but should not care where credentials are fetched from.
34 lines
943 B
TypeScript
Executable File
34 lines
943 B
TypeScript
Executable File
#!/bin/sh
|
|
//bin/true; exec deno run -A "$0" "$@"
|
|
import {
|
|
antiDuplicationPolicy,
|
|
hellthreadPolicy,
|
|
pipeline,
|
|
rateLimitPolicy,
|
|
readStdin,
|
|
writeStdout,
|
|
} from 'https://gitlab.com/soapbox-pub/strfry-policies/-/raw/develop/mod.ts';
|
|
import ldapPolicy from './ldap-policy.ts';
|
|
import { load } from "https://deno.land/std@0.224.0/dotenv/mod.ts";
|
|
|
|
const dirname = new URL('.', import.meta.url).pathname;
|
|
await load({ envPath: `${dirname}/.env`, export: true });
|
|
|
|
const ldapConfig = {
|
|
url: Deno.env.get("LDAP_URL"),
|
|
bindDN: Deno.env.get("LDAP_BIND_DN"),
|
|
password: Deno.env.get("LDAP_PASSWORD"),
|
|
searchDN: Deno.env.get("LDAP_SEARCH_DN"),
|
|
}
|
|
|
|
for await (const msg of readStdin()) {
|
|
const result = await pipeline(msg, [
|
|
[hellthreadPolicy, { limit: 10 }],
|
|
[antiDuplicationPolicy, { ttl: 60000, minLength: 50 }],
|
|
[rateLimitPolicy, { whitelist: ['127.0.0.1'] }],
|
|
[ldapPolicy, ldapConfig],
|
|
]);
|
|
|
|
writeStdout(result);
|
|
}
|