Skip to content

Commit 5b02009

Browse files
authored
Add docs section on Security and Privacy (#53)
* Add docs section on Security and Privacy
1 parent 6c6875e commit 5b02009

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default defineConfig({
2424
items: [
2525
{ text: "What is Protomaps?", link: "/" },
2626
{ text: "Getting Started", link: "/guide/getting-started" },
27+
{ text: "Security and Privacy", link: "/guide/security-privacy" },
2728
],
2829
},
2930
{

guide/security-privacy.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: Security and Privacy
3+
outline: deep
4+
---
5+
6+
# Security and Privacy
7+
8+
## Applications
9+
10+
Protomaps is designed for simple, secure and privacy-enabled map publishing, and is especially suited for:
11+
12+
* Maps for humanitarian operations, adversarial environments or emergency services. Protomaps enables maps to **work 100% offline**, meaning there's less risk of data leaks or compromise.
13+
14+
* **Public sector**: Protomaps can power mapping applications in city government, using storage and servers already provisioned. It ensures user data is not transmitted to third party map APIs, and can enable [compliance in the European Union.](#gdpr)
15+
16+
## Checklist
17+
18+
### Storage buckets
19+
20+
Verify the **access level of your storage buckets.**
21+
22+
Hosting PMTiles from a public storage bucket and decoding via [pmtiles.js](/pmtiles/maplibre) is the simplest publishing method, but allows anyone to download your entire tileset. To limit access, use one of the [deployment options](/deploy/) for decoding on the server or in a serverless function.
23+
24+
### HTTPS
25+
26+
Ensure that you access your maps over HTTPS instead of plain HTTP.
27+
28+
Using HTTPS is also required for [HTTP/2](https://developer.mozilla.org/en-US/docs/Glossary/HTTP_2) and 3, which will make map viewing faster by [enabling more requests at a time compared to HTTP 1.1](https://developer.mozilla.org/en-US/docs/Web/HTTP/Connection_management_in_HTTP_1.x#domain_sharding).
29+
30+
### CORS
31+
32+
[Cross-Origin Resource Sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) limits the sites that are allowed to embed your hosted resources, such as PMTiles archives, ZXY tile endpoints and TileJSON.
33+
34+
Check the [Cloud Storage](/pmtiles/cloud-storage) docs for your platform for how to configure CORS.
35+
36+
Avoid the `*` wildcard value for `Access-Control-Allow-Origin` for production traffic.
37+
38+
### Map Resources
39+
40+
Even if your PMTiles archives or tile endpoints come from your own infrastructure, other resources on a web map may come from an external origin. These include:
41+
42+
* Map rendering library JavaScript.
43+
44+
* Map rendering library CSS Stylesheets.
45+
46+
* For MapLibre GL: Map style JSON, spritesheets, fontstacks, and RTL (right-to-left) text plugins. See [Example Application](#example-application) below.
47+
48+
* Use Subresource Integrity to ensure that libraries from third parties are not compromised. Example:
49+
50+
```html
51+
<script
52+
src="https://unpkg.com/pmtiles@3.0.7/dist/pmtiles.js"
53+
integrity="sha384-MjejsnWXHmuz93aE35YWLh5AbS/6ceRB3Vb+ukOwqFzJRTpQ8vvbkLbNV7I0QK4f"
54+
crossorigin="anonymous"
55+
></script>
56+
```
57+
58+
## GDPR
59+
60+
::: info
61+
This is not a substitute for legal advice.
62+
:::
63+
64+
The European Union's [General Data Protection Regulation (GDPR)](https://gdpr.eu) regulates how companies store and transmit personal data.
65+
66+
Using Protomaps for your web map can **eliminate third party data controllers and processors**, making it much easier for sites to comply with GDPR.
67+
68+
Hosting [PMTiles](/pmtiles/) via your existing cloud storage or server is a first step - a typical map application has many other components.
69+
70+
### Example Application
71+
72+
Below is a complete example of a map application that avoids third-party data processors. As long as all linked assets are on your own GDPR-compliant static storage, no third party data processors or controllers are required.
73+
74+
```html{4-7,15,23-24}
75+
<html>
76+
<head>
77+
<meta charset="utf-8"/>
78+
<link rel="stylesheet" href="maplibre-gl.css">
79+
<script src="maplibre-gl.js"></script>
80+
<script src="pmtiles.js"></script>
81+
<script src="protomaps-themes-base.js"></script>
82+
</head>
83+
<body>
84+
<div id="map" style="height: 100%; width: 100%"></div>
85+
<script type="text/javascript">
86+
let protocol = new pmtiles.Protocol();
87+
maplibregl.addProtocol("pmtiles", protocol.tile);
88+
maplibregl.setRTLTextPlugin(
89+
"mapbox-gl-rtl-text.min.js",
90+
true,
91+
);
92+
const map = new maplibregl.Map({
93+
container: "map",
94+
zoom: 12,
95+
center: [11.24962,43.77078],
96+
style: {
97+
glyphs: "fonts/{fontstack}/{range}.pbf",
98+
sprites: "sprites/v3/light",
99+
version: 8,
100+
sources: {
101+
protomaps: {
102+
type: "vector",
103+
url: "pmtiles://firenze.pmtiles",
104+
attribution: '© <a href="https://openstreetmap.org">OpenStreetMap</a>'
105+
},
106+
},
107+
layers: protomaps_themes_base.default("protomaps", "light")
108+
},
109+
});
110+
</script>
111+
</body>
112+
</html>
113+
```
114+
115+
* `maplibre-gl.js`, `maplibre-gl.css` - JavaScript and CSS for the MapLibre GL rendering library.
116+
* `pmtiles.js` - JavaScript for decoding PMTiles archives in the browser.
117+
* `protomaps-themes-base.js` - JavaScript for creating a MapLibre GL style for a basemap tileset.
118+
* `mapbox-gl-rtl-text.min.js` - MapLibre plugin for supporting right-to-left languages.
119+
* `fonts/{fontstack}/{range}.pbf` - Font glyphs for rendering labels, available at [protomaps/basemaps-assets](https://github.com/protomaps/basemaps-assets).
120+
* `sprites/{version/{theme}` - Sprites for basemap icons, available at [protomaps/basemaps-assets](https://github.com/protomaps/basemaps-assets).

0 commit comments

Comments
 (0)