parent
0af975b3d9
commit
b5e1e41410
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: Crowdsec
|
||||||
|
description: Crowdsec Widget Configuration
|
||||||
|
---
|
||||||
|
|
||||||
|
Learn more about [Crowdsec](https://crowdsec.net).
|
||||||
|
|
||||||
|
Get your API key by registering a bouncer with your instance, see the [Crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro#bouncers).
|
||||||
|
|
||||||
|
Allowed fields: ["totalDecisions", "activeBans"]
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
widget:
|
||||||
|
type: crowdsec
|
||||||
|
url: http://crowdsechostorip:port
|
||||||
|
key: yourcrowdsecbouncerkey
|
||||||
|
```
|
@ -0,0 +1,39 @@
|
|||||||
|
import { useTranslation } from "next-i18next";
|
||||||
|
|
||||||
|
import Container from "components/services/widget/container";
|
||||||
|
import Block from "components/services/widget/block";
|
||||||
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
|
export default function Component({ service }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { widget } = service;
|
||||||
|
|
||||||
|
const { data: bansData, error: bansError } = useWidgetAPI(widget, "bans");
|
||||||
|
const { data: captchasData, error: captchasError } = useWidgetAPI(widget, "captchas");
|
||||||
|
const { data: rateLimitsData, error: rateLimitsError } = useWidgetAPI(widget, "rateLimits");
|
||||||
|
|
||||||
|
if (bansError || captchasError || rateLimitsError) {
|
||||||
|
return <Container service={service} error={bansError ?? captchasError ?? rateLimitsError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bansData && !captchasData && !rateLimitsData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="crowdsec.bans" />
|
||||||
|
<Block label="crowdsec.captchas" />
|
||||||
|
<Block label="crowdsec.rateLimits" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(bansData);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="crowdsec.bans" value={t("common.number", { value: bansData?.length ?? 0 })} />
|
||||||
|
<Block label="crowdsec.captchas" value={t("common.number", { value: captchasData?.length ?? 0 })} />
|
||||||
|
<Block label="crowdsec.rateLimits" value={t("common.number", { value: rateLimitsData?.length ?? 0 })} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/v1/{endpoint}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
bans: {
|
||||||
|
endpoint: "decisions?type=ban&origins=crowdsec",
|
||||||
|
},
|
||||||
|
captchas: {
|
||||||
|
endpoint: "decisions?type=captcha&origins=crowdsec",
|
||||||
|
},
|
||||||
|
rateLimits: {
|
||||||
|
endpoint: "decisions?type=rate-limit&origins=crowdsec",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
Loading…
Reference in new issue