add fortinet integration example
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0942fb132f
commit
f8be95c8d0
7
hypd/examples/fortigate/hypdconfig.json
Normal file
7
hypd/examples/fortigate/hypdconfig.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"networkInterface": "enp0s3",
|
||||||
|
"preSharedKeyDirectory": "./secrets/",
|
||||||
|
"successAction": "./examples/fortigate/openfortigate.sh %s",
|
||||||
|
"timeoutSeconds": 0,
|
||||||
|
"timeoutAction": ""
|
||||||
|
}
|
33
hypd/examples/fortigate/openfortigate.sh
Executable file
33
hypd/examples/fortigate/openfortigate.sh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Make sure you have environment variables set for FORTIGATE_MGMT_URL, FORTIGATE_API_TOKEN and FORTIGATE_ADDRESS_OBJECT_GROUP
|
||||||
|
# Examples:
|
||||||
|
export FORTIGATE_MGMT_URL="https://69.4.20.10:8443"
|
||||||
|
export FORTIGATE_API_KEY="5fkwkkzgQ4s31bdH60qsxxfN093zgt"
|
||||||
|
export FORTIGATE_ADDRESS_OBJECT_GROUP="hyp-allowed-clients"
|
||||||
|
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Usage: $0 <srcip>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $FORTIGATE_MGMT_URL
|
||||||
|
echo $1
|
||||||
|
|
||||||
|
# Create the address object
|
||||||
|
curl "$FORTIGATE_MGMT_URL/api/v2/cmdb/firewall/address?datasource=1" \
|
||||||
|
-X "POST" \
|
||||||
|
-H "Authorization: Bearer $FORTIGATE_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
--data-raw "{\"name\":\"hyp_$1\",\"subnet\":\"$1/32\",\"color\":\"0\"}" \
|
||||||
|
--insecure # LOL - remove this if you want, but I want this to be easy for noobs
|
||||||
|
|
||||||
|
|
||||||
|
# Add to address object group
|
||||||
|
curl "$FORTIGATE_MGMT_URL/api/v2/cmdb/firewall/addrgrp/$FORTIGATE_ADDRESS_OBJECT_GROUP/member" \
|
||||||
|
-X "POST" \
|
||||||
|
-H "Authorization: Bearer $FORTIGATE_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
--data-raw "{\"name\":\"hyp_$1\"}" \
|
||||||
|
--insecure # And here too
|
Loading…
Reference in New Issue
Block a user