vgs-django-pii-sample
Sample of using VGS for securing PII data(Django).
This demo app demonstrates a typical scenario for secure/revealing traffic from customer application to a payments operator.
- Installed Docker
- Installed ngrok
- Account on checkr.com
- Clone this repository
- Ensure both
INBOUND_ROUTE
andOUTBOUND_ROUTE
inidVerification/settings.py
are empty. 2.1 EnsureVGS_INBOUND_URL
indocker-compose.yml
is set tohttp://vgs-django-sample:8000
. Why we use Nginx - Set your
CHECKER_API_KEY
indocker-compose.yml
- Run
rerun.sh
script
Application will be started in a Docker container and available at http://localhost:8001/app/
Before integrating with VGS, the application works but it stores all PII (Peronsally identifiable information) data in storage.
- Force
ngrok
to specify a fixed host name via the command-line-host-header
flag:
ngrok http -bind-tls=true -subdomain=vgssl5 -host-header=${VGS_TENANT_IDENTIFER}.sandbox.verygoodproxy.com 8000
NOTE: Can also simply create a random subdomain without using the static paid feature above for ngrok
ngrok http 8000
- Please set the follow flag in django’s
settings.py
:
ALLOWED_HOSTS = ['localhost', '.verygoodproxy.com']
Once these configurations are set, ngrok
and django
play nicely together.
To make the local application visible from internet run ngrok ngrok http 8000
(not 8001
- used by Nginx). Use ngrok URI for setting up inbound route.
- Go to VGS-Dashboard, create a new organization, create a new vault. This is where we will store PII data.
- Setup
inboud
traffic protection:- go to
Routes
- create new inbound route:
Add new route
->New inbound route
- set
Upstream Host
to thengrok
endpoint from above (e.g.https://<some id>.ngrok.io
-> localhost:8000)
- go to
- Setup redact on request filter to protected our system from storing PII data in our DB:
Conditions
:HTTP Method
equals
POST
Pathinfo
equals
/app/add
Phase
On request
REDACT
Form
Fields in FormData
SSN
driver_license_number
- leave all other fields with by default value
- To make data readable for the customer who owns this data, lets
Add filter
, that will reveal PII data in client's response:- add new filter in the
inbound
route Conditions
:Pathinfo
begins with
/app/api/data
HTTP Method
equals
GET
ContentType
equals
application/json
Phase
On response
REVEAL
Json
Fields in JSON path
$.social_security_number
$.driver_license_number
- leave all other fields with by default value
- add new filter in the
- Click
Save
button and check result of Inbound routes creation inRoutes
.
-
Setup
outbound
route for processing original data on checkr.com.- go to
Routes
- create new outbound route:
Add new route
->New outbound route
- set
Upstream Host
withcheckr
API hostapi.checkr.com
- go to
-
Setup filter for revealing PII data in client's request to
Checkr
:Conditions
:Pathinfo
equals
/v1/candidates
HTTP Method
equals
POST
Phase
On request
REVEAL
Json
Fields in JSON path
$.ssn
$.driver_license_number
- leave all other field values as is
-
To get rid of storing user's PII data from
Checkr
service response add newREDACT
on response
filter in theoutbound
routeConditions
:Pathinfo
equals
/v1/candidates
Phase
On response
REDACT
Json
Fields in JSON path
$.ssn
$.driver_license_number
-
Click
Save
button and check the result of Outbound routes creation inRoutes
.
- Use
Vault URLs
it in our app:
- copy the URLS
docker-compose.yml
Why we use Nginx
INBOUND_ROUTE='https://tntdbopmilp.SANDBOX.verygoodproxy.com' #inbound
and to /idVerification/settings.py
OUTBOUND_ROUTE='https://US2yjMXkaJddDpxSCj1BCFb7:056c520b-5564-4750-bb96-d774104090e0@tntdbopmilp.SANDBOX.verygoodproxy.com:8080' #outbound
- Our app is now secured by VGS. Lets check it out.
- restart
rerun.sh
script - go to http://localhost:8001/app/
- add new data using UI form
- go to data original view and try to check it on
Checkr
service
Sample application has CSRF protection. Protection based on 2 tockens that generated/verified by Django server. One of them stores in browser cookies, so we need same host for django server and VGS proxy to allow browser add CSRF cookie to VGS proxy request.
How it works:
Want to just jump right in? Check out our getting started guide.
Very Good Security (VGS) allows you to enhance your security standing while maintaining the utility of your data internally and with third-parties. As an added benefit, we accelerate your compliance certification process and help you quickly obtain security-related compliances that stand between you and your market opportunities.
To learn more, visit us at https://www.verygoodsecurity.com/
This project is licensed under the MIT license. See the LICENSE file for details.