This project demonstrates how to implement an IP ban list in a web server using the Gin-Gonic framework in Go and using Snyk for Security checks. It includes middleware to check if an IP is banned and an endpoint to ban the IP, simulating a failed login attempt.
- Middleware to check if an IP is banned
- Endpoint to ban an IP
- Configurable ban duration
- Go 1.16 or later
- Gin-Gonic framework
-
Clone the repository:
git clone https://github.com/yourusername/ip-ban-list.git cd ip-ban-list
-
Install the necessary dependencies:
go mod tidy
-
Run the server:
go run main.go
-
The server will start on
http://localhost:8080
. -
To test the banning functionality, access the
/banit
endpoint from your browser or usecurl
:curl http://localhost:8080/banit
This will ban your IP for the specified duration (default is 10 minutes).
-
If you try to access the
/banit
endpoint again during the ban period, you will receive a403 Forbidden
response.
This project is to show example of GIN rate-limiting with Snyk integration.