-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This provides dynamic IP address whitelisting for instances, using iptables rules, in order to add an extra layer of protection. This can be enabled by setting `enable_ip_whitelisting = true` in the server configuration. No client changes are required: any API call to create an instance or retrieve its details will result in the user's IP address being stored in a whitelist and the iptables rules updated to reflect this. See the new section in `README.md` for further details of the design.
- Loading branch information
Showing
18 changed files
with
694 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- +migrate Up | ||
CREATE TABLE whitelisted_addresses ( | ||
ip_address inet NOT NULL, | ||
instance_id integer NOT NULL REFERENCES instances (id) ON DELETE CASCADE, | ||
created_at timestamptz NOT NULL, | ||
updated_at timestamptz NOT NULL, | ||
PRIMARY KEY (ip_address, instance_id) | ||
); | ||
|
||
-- +migrate Down | ||
DROP TABLE whitelisted_addresses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type WhitelistedAddress struct { | ||
// Given that we're not serving this model via JSON:API, we don't need a | ||
// surrogate key (e.g. 'ID'). The IP address and instance ID are used as a composite key. | ||
IPAddress string | ||
Instance *Instance | ||
CreatedAt time.Time | ||
UpdatedAt time.Time | ||
} | ||
|
||
func NewWhitelistedAddress(ipaddress string, instance *Instance) WhitelistedAddress { | ||
return WhitelistedAddress{ | ||
IPAddress: ipaddress, | ||
Instance: instance, | ||
CreatedAt: time.Now(), | ||
UpdatedAt: time.Now(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.