NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi,

I have setup OSM server using mod-tiles and renderd. I want to implement key based access control to map tiles, something similar to Google map key. How can I do this?

asked 21 Jan '17, 09:02

Reshma%20Maner's gravatar image

Reshma Maner
235303136
accept rate: 0%

Hi

I need some more help in this, if somebody can guide me what exactly do I need to do if I want to implementing API Key based access control for mod-tiles.

my tileserver_site.conf file contains following lines which are commented.

AddTileConfig /folder/ TileSetName

How do I create APIs and use them for allowing map access?

(10 Jul '18, 12:31) Reshma Maner

There are many possible ways to do that. You could certainly add key handling directly to mod_tile if some C programming isn't too big a hurdle. Another option (but one that requires a config file reload on Apache every time the list changes) is to do this via Apache, either by creating one "AddTileConfig" directive per API key or by using somethig like mod_perl to generate these AddTileConfig rules programmatically, reading the keys from a file.

permanent link

answered 21 Jan '17, 22:18

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

edited 31 Mar '17, 17:38

Could you provide an example of 'creating one "AddTileConfig" directive per API key'?

(31 Mar '17, 17:06) rgwozdz
1

Sure: Instead of

AddTileConfig /tile mycoolmapstyle

which will lead Apache to map http://somehost/tile/z/x/y.png to tiles of your "mycoolmapstyle" type, you would

AddTileConfig /apikey1 mycoolmapstyle
AddTileConfig /apikey2 mycoolmapstyle
AddTileConfig /apikey3 mycoolmapstyle

and so on. These API keys, if long enough, cannot be guessed so they are "secret". Instead of the above, it is also possible to use mod_perl to read the API keys from a file and then generate the AddTileConfig directives.

(31 Mar '17, 17:38) Frederik Ramm ♦
1

Thanks very much, that really helps.

(31 Mar '17, 18:24) rgwozdz

Hi,

If I add an apikey in tileserver_site.conf as given above, then what changes do I need to make in my OpenLayer code to access the map?

(24 Jul '17, 10:25) Reshma Maner
1

When creating the tile layer in OpenLayers you can specify the URL to use. In your case the URL would have to look like http://myserver/apikey1/${z}/${x}/${y}.png.

(24 Jul '17, 13:24) Frederik Ramm ♦

Hi, I dont understand how it works. Please, explain me. What means "mycoolmapstyle" in the example? I f i create a "/apikey1" i dont need create a symbolic link to /var/lib/mod_tile? Do you have an example of mod_perl and where i save this files?

Thank you.

permanent link

answered 10 May '18, 23:36

Flaviomx14's gravatar image

Flaviomx14
241
accept rate: 0%

edited 10 May '18, 23:38

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×535
×9

question asked: 21 Jan '17, 09:02

question was seen: 4,766 times

last updated: 10 Jul '18, 12:51

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum