Skip to content

Commit

Permalink
Simplifying database setup and fixing region listing for localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
KingAkeem committed Apr 27, 2024
1 parent e27e2de commit 3d5a03f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 41 deletions.
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

psql -U postgres -f sql/initialize_database.sql
psql -U postgres -d gorm -c "GRANT USAGE ON SCHEMA public TO gorm;"
94 changes: 54 additions & 40 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,64 @@
{
"database": {
"host": "localhost",
"port": "5432",
"port": "5433",
"user": "gorm",
"password": "gorm",
"dbname": "gorm"
},
"host": "http://localhost",
"port": ":8081",
"endpoints": [{
"plugins": [{
"type": "monitor",
"settings": {
"active_mode": false,
"verbose": true,
"publishers": [{
"type": "file",
"name": "monitor-log",
"directory": "."
}]
}
},
"endpoints": [
{
"type":"ratelimiter",
"settings":{
"active_mode": true,
"rate": 1,
"publishers": [{
"type": "slack",
"token": "xoxb-198202255696-5682091092327-m8IHyjQEnO6FdIIslpzjq2nz",
"channelID": "C5UTW0J6N"
}]
}
},
{
"type": "requestfilter",
"settings":{
"active_mode": true,
"ip-blacklist":[],
"ip-whitelist": [],
"region-whitelist": ["US", "IN"],
"region-blacklist": []
}
}],
"methods": ["GET", "POST"],
"external": "/their-client-api",
"internal": "/our-customers-api"
}]
}
"plugins": [
{
"type": "monitor",
"settings": {
"active_mode": false,
"verbose": true,
"publishers": [
{
"type": "file",
"name": "monitor-log",
"directory": "."
}
]
}
},
{
"type": "ratelimiter",
"settings": {
"active_mode": true,
"rate": 1,
"publishers": [
{
"type": "slack",
"token": "xoxb-198202255696-5682091092327-m8IHyjQEnO6FdIIslpzjq2nz",
"channelID": "C5UTW0J6N"
}
]
}
},
{
"type": "requestfilter",
"settings": {
"active_mode": true,
"ip-blacklist": [],
"ip-whitelist": [],
"region-whitelist": [
"US",
"IN"
],
"region-blacklist": []
}
}
],
"methods": [
"GET",
"POST"
],
"external": "/their-client-api",
"internal": "/our-customers-api"
}
]
}
5 changes: 4 additions & 1 deletion plugins/ipfilter/requestfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ func (p *RequestFilterPlugin) Handle(r *http.Request) error {

// Handle region-based restrictions
region := getRegionForIP(ip)
if len(p.regionBlacklist) > 0 {
if region == "" {
return nil
}

if len(p.regionBlacklist) > 0 {
for _, restrictedRegion := range p.regionBlacklist {
if region == restrictedRegion {
req, err := database.NewRequest(r, "regionblacklist")
Expand Down

0 comments on commit 3d5a03f

Please sign in to comment.