SlideShare a Scribd company logo
1 of 22
SAASY MAPS - USING DJANGO-
TENANTS AND GEODJANGO TO
PROVIDE WEB-GIS SOFTWARE-AS-A-
SERVICE
Anusha Chickermane
OBJECTIVES
• create a semi-isolated multi-tenant architecture using django-
tenants+postgresql
• build on top of it using geodjango+postgis+openlayers to provide
individualised web mapping services to different clients
• performance and security implications of this approach
• We achieve this by creating a website that shows accident point locations
for three different counties and brings up the associated attributes of
date_of_accident and number_of_vehicles
• Code and this presentation at https://github.com/anushamc/foss4guk-
django-tenants
SOFTWARE AS A SERVICE
• SaaS - software deployment
model where applications are
remotely hosted by the service
provider and made available to
customers on demand
• Eg. github.io, has multiple tenants
• tombatossals.github.io/angular-
openlayers-directive/ – user tombatossals
example page
• blueimp.github.io/jQuery-File-Upload/ -
user bluimp’s example page
• We look at the top 2 layers of the SaaS
architecture – Saas apps and
Application services
SAAS SECURITY CONCERNS
• SaaS deployment model – Aws or self-hosted?
• Data security(encryption, app vulnerability) – Django+postgres
• Network security (SSL) – Django
• Regulatory compliance
• Data segregation – tenant-schemas
• Availability
• Backup
• Identity management and sign-on process - Django
DATA SEGRATION
• django-tenants lies in the
middle: shared database,
separate schemas
• Isolated – more secure, but
costlier to implement and
maintain, and lower
performance
• Shared – less secure, but
easier to implement and
better performance
• The right choice on the
spectrum depends on
business requirements and
sensitivity of the data
PERFORMANCE
• Not as memory intensive as having separate databases
• As the number of schemas (i.e. tenants) grows, propagating model
(i.e. database structure)changes will take longer – parallel migrations
help reduce this performance hit
• Since the same database models are used across tenants,
customisation of each tenant is limited to only changing the look &
feel via templates – i.e cant have one geometry field for one tenant
and two for another in the same model
• If using main-domain and subdomain, eg github.io and
bluimp.github.io, need to watch out for cookie attacks across
subdomains
THE DJANGO FRAMEWORK
• MVT – Model View Template
• Model – defines the data
structure and handles the
database queries
• View – determines what data
from the model should be
returned in HTTP response
• Template – renders data in
HTML(or JSON or XML) and
makes it look pretty
A TYPICAL DJANGO PROJECT
• mysite/
• manage.py
• mysite/
• settings.py
• urls.py
• wsgi.py
• app/
• admin.py
• migrations/
• models.py
• static/
• css/
• js/
• templates/
• Index.html
• tests.py
• views.py
• manage.py – runserver,
makemigrations, migrate
• settings.py – database and site
settings
• urls.py – urls mapped to views
• admin – to create the admin interface
• Models – define the database
structure
• Templates – html files with Django
tags
• Views – handle get and post requests
DJANGO-TENANTS APP
• public_app – accessed from
the main domain i.e.
www.mainsite.com
• tenant_app – accessed from
the tenant’s sub-domain
• mysite/
• manage.py
• mysite/
• settings.py
• …
• public_app/
• admin.py
• migrations/
• …
• tenant_app/
• admin.py
• migrations/
• …
SETUP
• Boot from OS-Geo-Live
• Insert disk into CD drive, restart system and hold down F12 to access boot
options
• For windows 8 and above – Click on the power option (either on the Start
Screen or the Charms Bar) and then hold down the shift key while clicking on
Restart.
MODIFYING THE HOSTS FILE TO
SIMULATE DIFFERENT TENANTS
• Open the terminal and run the following command:
sudo vim /etc/hosts
• Near the top of the file, add the following lines:
127.0.0.1 mainsite.com
127.0.0.1 cumbria.mainsite.com
127.0.0.1 lancashire.mainsite.com
127.0.0.1 london.mainsite.com
• To exit the editor, press ESC and then type :wq
CREATING THE DATABASE
• Open pgAdmin III.
• Create a new database called ‘multi_county_db’.
• Add the postgis extension.
INSTALLING DJANGO, GEODJANGO AND
DJANGO-TENANTS
• Open the terminal and run
• Install pip and django:
sudo apt-get install python3-pip
sudo pip3 install django
• Install python bindings for postgres:
sudo apt-get install python3-psycopg2
• Install Django-tenants:
sudo pip3 install django-tenants
CREATING THE PROJECT
• Open the terminal and run
• Create the project
django-admin startproject multi_county
• Open the project and create apps
cd multi_county
python3 manage.py startapp public_app
python3 manage.py startapp tenant_app
• Replace contents of multi_countysettings.py with
https://raw.githubusercontent.com/anushamc/foss4guk-django-
tenants/master/multi_county/multi_county/settings.py
• Replace contents of public_appmodels.py with
https://raw.githubusercontent.com/anushamc/foss4guk-django-
tenants/master/multi_county/public_app/models.py
CREATING THE PROJECT
• Open the terminal and run
python3 manage.py migrate_schemas –-shared
• Replace contents of tenant_appmodels.py with
https://github.com/anushamc/foss4guk-django-
tenants/blob/master/multi_county/tenant_app/models.py
• Open the terminal and run
python3 manage.py makemigrations
python3 manage.py migrate_schemas
CREATING THE TENANTS********
• In the same folder as manage.py, download the file
create_tenants.py from
• Open the terminal and run
python3 manage.py shell < create_tenants.py
IMPORTING THE DATA
• Download the data for the schemas from
https://github.com/anushamc/foss4guk-django-
tenants/tree/master/data
• Go to PG Admin III and expand the schemas Lancashire, cumbria
and london
• Right-click the tenant_app_accident table for each county schema,
and select Import…
• In File Options tab, change type to csv and choose the relevant csv file
• In Columns uncheck id and geom
• In Misc. Options check header
• Click Import button
• Do this for all 3 county schemas
IMPORTING THE DATA
• From PG Admin III Run the following sql command on the database:
UPDATE antrim.tenant_app_accident SET geom=ST_GeomFromText('POINT(' ||
location_easting_osgr || ' ' || location_northing_osgr || ')',27700);
UPDATE lancashire.tenant_app_accident SET geom=ST_GeomFromText('POINT(' ||
location_easting_osgr || ' ' || location_northing_osgr || ')',27700);
UPDATE london.tenant_app_accident SET geom=ST_GeomFromText('POINT(' ||
location_easting_osgr || ' ' || location_northing_osgr || ')',27700);
CREATING THE TEMPLATE
• Create a new folder called static in tenant_app folder, and extract into it
javascript-libraries.zip from https://github.com/anushamc/foss4guk-django-
tenants/blob/master/javascript-libraries.zip?raw=true
• Create a new folder called templates in tenant_app folder and place file
index.html from https://raw.githubusercontent.com/anushamc/foss4guk-
django-tenants/master/multi_county/tenant_app/templates/index.html
• Create a new folder called js in tenant_appstatic folder and place file
accidents.js from https://raw.githubusercontent.com/anushamc/foss4guk-
django-tenants/master/multi_county/tenant_app/static/js/accidents.js
CREATING THE TEMPLATE
• Create a new folder called css in tenant_appstatic folder and
place files themes.min.css and accidents.css from
https://raw.githubusercontent.com/anushamc/foss4guk-django-
tenants/master/multi_county/tenant_app/static/css/theme.min.css
and https://raw.githubusercontent.com/anushamc/foss4guk-django-
tenants/master/multi_county/tenant_app/static/css/accidents.css
CREATING THE VIEW
• Replace the contents of the tenant_app/views.py file with
https://raw.githubusercontent.com/anushamc/foss4guk-django-
tenants/master/multi_county/tenant_app/views.py
• Replace the contents of the multi_county/urls.py file with
https://raw.githubusercontent.com/anushamc/foss4guk-django-
tenants/master/multi_county/multi_county/urls.py
• Open the terminal and run
python3 manage.py runserver
• Open mainsite.com:8000 to get an empty map,
cumbria.mainsite.com:8000 to get the accidents points layer from Cumbia,
london.mainsite.com:8000 to get London, and
lancashire.mainsite.com:8000 to get the data from Lancaster
Thank you for your time!

More Related Content

What's hot

pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
Command Prompt., Inc
 

What's hot (20)

pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Apache Spark Data Validation
Apache Spark Data ValidationApache Spark Data Validation
Apache Spark Data Validation
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
AWS CLIでAssumeRole
AWS CLIでAssumeRoleAWS CLIでAssumeRole
AWS CLIでAssumeRole
 
Deep Dive on the Amazon Aurora MySQL-compatible Edition - DAT301 - re:Invent ...
Deep Dive on the Amazon Aurora MySQL-compatible Edition - DAT301 - re:Invent ...Deep Dive on the Amazon Aurora MySQL-compatible Edition - DAT301 - re:Invent ...
Deep Dive on the Amazon Aurora MySQL-compatible Edition - DAT301 - re:Invent ...
 
Not a Security Boundary: Bypassing User Account Control
Not a Security Boundary: Bypassing User Account ControlNot a Security Boundary: Bypassing User Account Control
Not a Security Boundary: Bypassing User Account Control
 
게임을 위한 DynamoDB 사례 및 팁 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
게임을 위한 DynamoDB 사례 및 팁 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming게임을 위한 DynamoDB 사례 및 팁 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
게임을 위한 DynamoDB 사례 및 팁 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
 
AWS Black Belt Online Seminar 2017 Amazon DynamoDB
AWS Black Belt Online Seminar 2017 Amazon DynamoDB AWS Black Belt Online Seminar 2017 Amazon DynamoDB
AWS Black Belt Online Seminar 2017 Amazon DynamoDB
 
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
 
Amazon Redshiftへの移行方法と設計のポイント(db tech showcase 2016)
Amazon Redshiftへの移行方法と設計のポイント(db tech showcase 2016)Amazon Redshiftへの移行方法と設計のポイント(db tech showcase 2016)
Amazon Redshiftへの移行方法と設計のポイント(db tech showcase 2016)
 
AWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design Pattern
AWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design PatternAWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design Pattern
AWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design Pattern
 
20180221 AWS Black Belt Online Seminar AWS Lambda@Edge
20180221 AWS Black Belt Online Seminar AWS Lambda@Edge20180221 AWS Black Belt Online Seminar AWS Lambda@Edge
20180221 AWS Black Belt Online Seminar AWS Lambda@Edge
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 
DynamoDB設計のちょっとした技
DynamoDB設計のちょっとした技DynamoDB設計のちょっとした技
DynamoDB設計のちょっとした技
 
20190731 Black Belt Online Seminar Amazon ECS Deep Dive
20190731 Black Belt Online Seminar Amazon ECS Deep Dive20190731 Black Belt Online Seminar Amazon ECS Deep Dive
20190731 Black Belt Online Seminar Amazon ECS Deep Dive
 
MySQL Document Store를 활용한 NoSQL 개발
MySQL Document Store를 활용한 NoSQL 개발MySQL Document Store를 활용한 NoSQL 개발
MySQL Document Store를 활용한 NoSQL 개발
 
Google Cloud Platform monitoring with Zabbix
Google Cloud Platform monitoring with ZabbixGoogle Cloud Platform monitoring with Zabbix
Google Cloud Platform monitoring with Zabbix
 
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
 
Building a multitenant application with Django
Building a multitenant application with DjangoBuilding a multitenant application with Django
Building a multitenant application with Django
 
PySpark Best Practices
PySpark Best PracticesPySpark Best Practices
PySpark Best Practices
 

Viewers also liked

Developing Software As A Service App with Python & Django
Developing Software As A Service App with Python & DjangoDeveloping Software As A Service App with Python & Django
Developing Software As A Service App with Python & Django
Allan Mangune
 
2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python
Adam Hitchcock
 
Modelo, vista, controlador
Modelo, vista, controladorModelo, vista, controlador
Modelo, vista, controlador
Cecy Villalta
 
MODELO VISTA CONTROLADOR
MODELO VISTA CONTROLADORMODELO VISTA CONTROLADOR
MODELO VISTA CONTROLADOR
René Pilataxi
 
ZCA: A component architecture for Python
ZCA: A component architecture for PythonZCA: A component architecture for Python
ZCA: A component architecture for Python
Timo Stollenwerk
 

Viewers also liked (20)

Developing Software As A Service App with Python & Django
Developing Software As A Service App with Python & DjangoDeveloping Software As A Service App with Python & Django
Developing Software As A Service App with Python & Django
 
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to Services
 
¿Porqué Python? ...y Django
¿Porqué Python? ...y Django¿Porqué Python? ...y Django
¿Porqué Python? ...y Django
 
2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python
 
Django multi-tier
Django multi-tierDjango multi-tier
Django multi-tier
 
Django
DjangoDjango
Django
 
Criando websites a jato com Django
Criando websites a jato com DjangoCriando websites a jato com Django
Criando websites a jato com Django
 
Dia1
Dia1Dia1
Dia1
 
Django: desenvolvendo aplicações web de maneira simples e rápida!
Django: desenvolvendo aplicações web de maneira simples e rápida!Django: desenvolvendo aplicações web de maneira simples e rápida!
Django: desenvolvendo aplicações web de maneira simples e rápida!
 
Modelo, vista, controlador
Modelo, vista, controladorModelo, vista, controlador
Modelo, vista, controlador
 
MODELO VISTA CONTROLADOR
MODELO VISTA CONTROLADORMODELO VISTA CONTROLADOR
MODELO VISTA CONTROLADOR
 
ZCA: A component architecture for Python
ZCA: A component architecture for PythonZCA: A component architecture for Python
ZCA: A component architecture for Python
 
Cursos Isla 2007: Administración Avanzada Linux (DHCP)
Cursos Isla 2007: Administración Avanzada Linux (DHCP)Cursos Isla 2007: Administración Avanzada Linux (DHCP)
Cursos Isla 2007: Administración Avanzada Linux (DHCP)
 
Django: Desenvolvendo uma aplicação web em minutos
Django: Desenvolvendo uma aplicação web em minutosDjango: Desenvolvendo uma aplicação web em minutos
Django: Desenvolvendo uma aplicação web em minutos
 
Dev/Test Scenarios in the DevOps World
Dev/Test Scenarios in the DevOps WorldDev/Test Scenarios in the DevOps World
Dev/Test Scenarios in the DevOps World
 
Intro django
Intro djangoIntro django
Intro django
 
LCNUG 2015 - what's new for agile teams in TFS 2015
LCNUG 2015 -  what's new for agile teams in TFS 2015LCNUG 2015 -  what's new for agile teams in TFS 2015
LCNUG 2015 - what's new for agile teams in TFS 2015
 
Why Django
Why DjangoWhy Django
Why Django
 
Django Multi-DB in Anger
Django Multi-DB in AngerDjango Multi-DB in Anger
Django Multi-DB in Anger
 
Database Considerations for SaaS Products
Database Considerations for SaaS ProductsDatabase Considerations for SaaS Products
Database Considerations for SaaS Products
 

Similar to SaaSy maps - using django-tenants and geodjango to provide web-gis software-as-a-service

2013_protect_presentation
2013_protect_presentation2013_protect_presentation
2013_protect_presentation
Jeff Holland
 
Sa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administratorsSa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administrators
Sharon James
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
Christopher Schmitt
 
Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...
Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...
Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...
telestax
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the Trunk
Harold Giménez
 

Similar to SaaSy maps - using django-tenants and geodjango to provide web-gis software-as-a-service (20)

2013_protect_presentation
2013_protect_presentation2013_protect_presentation
2013_protect_presentation
 
Sa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administratorsSa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administrators
 
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty ProfileAAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
 
What's new in MongoDB 3.6?
What's new in MongoDB 3.6?What's new in MongoDB 3.6?
What's new in MongoDB 3.6?
 
Cloudify workshop at CCCEU 2014
Cloudify workshop at CCCEU 2014 Cloudify workshop at CCCEU 2014
Cloudify workshop at CCCEU 2014
 
Azure appservice
Azure appserviceAzure appservice
Azure appservice
 
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your ApplicationsThe Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
Rakuten Ichiba development Automation show case - Bamboo, Docker -
Rakuten Ichiba development Automation show case - Bamboo, Docker -Rakuten Ichiba development Automation show case - Bamboo, Docker -
Rakuten Ichiba development Automation show case - Bamboo, Docker -
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the Box
 
Effectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEM
 
Practical solutions for connections administrators
Practical solutions for connections administratorsPractical solutions for connections administrators
Practical solutions for connections administrators
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testing
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
 
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
 
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)
 
Presenting Data – An Alternative to the View Control
Presenting Data – An Alternative to the View ControlPresenting Data – An Alternative to the View Control
Presenting Data – An Alternative to the View Control
 
Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...
Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...
Mobicents Summit 2012 - Silvano Girardi - InPhonex's migration to Mobicents S...
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the Trunk
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 

SaaSy maps - using django-tenants and geodjango to provide web-gis software-as-a-service

  • 1. SAASY MAPS - USING DJANGO- TENANTS AND GEODJANGO TO PROVIDE WEB-GIS SOFTWARE-AS-A- SERVICE Anusha Chickermane
  • 2. OBJECTIVES • create a semi-isolated multi-tenant architecture using django- tenants+postgresql • build on top of it using geodjango+postgis+openlayers to provide individualised web mapping services to different clients • performance and security implications of this approach • We achieve this by creating a website that shows accident point locations for three different counties and brings up the associated attributes of date_of_accident and number_of_vehicles • Code and this presentation at https://github.com/anushamc/foss4guk- django-tenants
  • 3. SOFTWARE AS A SERVICE • SaaS - software deployment model where applications are remotely hosted by the service provider and made available to customers on demand • Eg. github.io, has multiple tenants • tombatossals.github.io/angular- openlayers-directive/ – user tombatossals example page • blueimp.github.io/jQuery-File-Upload/ - user bluimp’s example page • We look at the top 2 layers of the SaaS architecture – Saas apps and Application services
  • 4. SAAS SECURITY CONCERNS • SaaS deployment model – Aws or self-hosted? • Data security(encryption, app vulnerability) – Django+postgres • Network security (SSL) – Django • Regulatory compliance • Data segregation – tenant-schemas • Availability • Backup • Identity management and sign-on process - Django
  • 5. DATA SEGRATION • django-tenants lies in the middle: shared database, separate schemas • Isolated – more secure, but costlier to implement and maintain, and lower performance • Shared – less secure, but easier to implement and better performance • The right choice on the spectrum depends on business requirements and sensitivity of the data
  • 6. PERFORMANCE • Not as memory intensive as having separate databases • As the number of schemas (i.e. tenants) grows, propagating model (i.e. database structure)changes will take longer – parallel migrations help reduce this performance hit • Since the same database models are used across tenants, customisation of each tenant is limited to only changing the look & feel via templates – i.e cant have one geometry field for one tenant and two for another in the same model • If using main-domain and subdomain, eg github.io and bluimp.github.io, need to watch out for cookie attacks across subdomains
  • 7. THE DJANGO FRAMEWORK • MVT – Model View Template • Model – defines the data structure and handles the database queries • View – determines what data from the model should be returned in HTTP response • Template – renders data in HTML(or JSON or XML) and makes it look pretty
  • 8. A TYPICAL DJANGO PROJECT • mysite/ • manage.py • mysite/ • settings.py • urls.py • wsgi.py • app/ • admin.py • migrations/ • models.py • static/ • css/ • js/ • templates/ • Index.html • tests.py • views.py • manage.py – runserver, makemigrations, migrate • settings.py – database and site settings • urls.py – urls mapped to views • admin – to create the admin interface • Models – define the database structure • Templates – html files with Django tags • Views – handle get and post requests
  • 9. DJANGO-TENANTS APP • public_app – accessed from the main domain i.e. www.mainsite.com • tenant_app – accessed from the tenant’s sub-domain • mysite/ • manage.py • mysite/ • settings.py • … • public_app/ • admin.py • migrations/ • … • tenant_app/ • admin.py • migrations/ • …
  • 10. SETUP • Boot from OS-Geo-Live • Insert disk into CD drive, restart system and hold down F12 to access boot options • For windows 8 and above – Click on the power option (either on the Start Screen or the Charms Bar) and then hold down the shift key while clicking on Restart.
  • 11. MODIFYING THE HOSTS FILE TO SIMULATE DIFFERENT TENANTS • Open the terminal and run the following command: sudo vim /etc/hosts • Near the top of the file, add the following lines: 127.0.0.1 mainsite.com 127.0.0.1 cumbria.mainsite.com 127.0.0.1 lancashire.mainsite.com 127.0.0.1 london.mainsite.com • To exit the editor, press ESC and then type :wq
  • 12. CREATING THE DATABASE • Open pgAdmin III. • Create a new database called ‘multi_county_db’. • Add the postgis extension.
  • 13. INSTALLING DJANGO, GEODJANGO AND DJANGO-TENANTS • Open the terminal and run • Install pip and django: sudo apt-get install python3-pip sudo pip3 install django • Install python bindings for postgres: sudo apt-get install python3-psycopg2 • Install Django-tenants: sudo pip3 install django-tenants
  • 14. CREATING THE PROJECT • Open the terminal and run • Create the project django-admin startproject multi_county • Open the project and create apps cd multi_county python3 manage.py startapp public_app python3 manage.py startapp tenant_app • Replace contents of multi_countysettings.py with https://raw.githubusercontent.com/anushamc/foss4guk-django- tenants/master/multi_county/multi_county/settings.py • Replace contents of public_appmodels.py with https://raw.githubusercontent.com/anushamc/foss4guk-django- tenants/master/multi_county/public_app/models.py
  • 15. CREATING THE PROJECT • Open the terminal and run python3 manage.py migrate_schemas –-shared • Replace contents of tenant_appmodels.py with https://github.com/anushamc/foss4guk-django- tenants/blob/master/multi_county/tenant_app/models.py • Open the terminal and run python3 manage.py makemigrations python3 manage.py migrate_schemas
  • 16. CREATING THE TENANTS******** • In the same folder as manage.py, download the file create_tenants.py from • Open the terminal and run python3 manage.py shell < create_tenants.py
  • 17. IMPORTING THE DATA • Download the data for the schemas from https://github.com/anushamc/foss4guk-django- tenants/tree/master/data • Go to PG Admin III and expand the schemas Lancashire, cumbria and london • Right-click the tenant_app_accident table for each county schema, and select Import… • In File Options tab, change type to csv and choose the relevant csv file • In Columns uncheck id and geom • In Misc. Options check header • Click Import button • Do this for all 3 county schemas
  • 18. IMPORTING THE DATA • From PG Admin III Run the following sql command on the database: UPDATE antrim.tenant_app_accident SET geom=ST_GeomFromText('POINT(' || location_easting_osgr || ' ' || location_northing_osgr || ')',27700); UPDATE lancashire.tenant_app_accident SET geom=ST_GeomFromText('POINT(' || location_easting_osgr || ' ' || location_northing_osgr || ')',27700); UPDATE london.tenant_app_accident SET geom=ST_GeomFromText('POINT(' || location_easting_osgr || ' ' || location_northing_osgr || ')',27700);
  • 19. CREATING THE TEMPLATE • Create a new folder called static in tenant_app folder, and extract into it javascript-libraries.zip from https://github.com/anushamc/foss4guk-django- tenants/blob/master/javascript-libraries.zip?raw=true • Create a new folder called templates in tenant_app folder and place file index.html from https://raw.githubusercontent.com/anushamc/foss4guk- django-tenants/master/multi_county/tenant_app/templates/index.html • Create a new folder called js in tenant_appstatic folder and place file accidents.js from https://raw.githubusercontent.com/anushamc/foss4guk- django-tenants/master/multi_county/tenant_app/static/js/accidents.js
  • 20. CREATING THE TEMPLATE • Create a new folder called css in tenant_appstatic folder and place files themes.min.css and accidents.css from https://raw.githubusercontent.com/anushamc/foss4guk-django- tenants/master/multi_county/tenant_app/static/css/theme.min.css and https://raw.githubusercontent.com/anushamc/foss4guk-django- tenants/master/multi_county/tenant_app/static/css/accidents.css
  • 21. CREATING THE VIEW • Replace the contents of the tenant_app/views.py file with https://raw.githubusercontent.com/anushamc/foss4guk-django- tenants/master/multi_county/tenant_app/views.py • Replace the contents of the multi_county/urls.py file with https://raw.githubusercontent.com/anushamc/foss4guk-django- tenants/master/multi_county/multi_county/urls.py • Open the terminal and run python3 manage.py runserver • Open mainsite.com:8000 to get an empty map, cumbria.mainsite.com:8000 to get the accidents points layer from Cumbia, london.mainsite.com:8000 to get London, and lancashire.mainsite.com:8000 to get the data from Lancaster
  • 22. Thank you for your time!

Editor's Notes

  1. Image from http://www.infosectoday.com/Articles/Securing_SaaS_Applications.htm
  2. Cookie attacks - https://github.com/blog/1466-yummy-cookies-across-domains
  3. Image from - http://brionas.github.io/2013/11/15/share-django/
  4. Structure based on https://docs.djangoproject.com/en/1.9/intro/tutorial01/
  5. Right click Databases to create a new database Open Plugins>PostGIS Shapefile Import/Export Manager