Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple mapbooks support #59

Closed
cassiel74 opened this issue Oct 22, 2014 · 12 comments
Closed

Multiple mapbooks support #59

cassiel74 opened this issue Oct 22, 2014 · 12 comments

Comments

@cassiel74
Copy link

Please add multiple mapbooks support - and related services - out of the box.
Regards

theduckylittle pushed a commit to geomoose/geomoose-services that referenced this issue Dec 12, 2014
@theduckylittle
Copy link
Member

Okay, so this solution still requires some documentation but now the local_settings file can be overridden with the environment variable, which can be set with Apache.

@theduckylittle theduckylittle added this to the 2.8 milestone Dec 12, 2014
@elil
Copy link
Member

elil commented Dec 12, 2014

How would this be done?
Would it be in Apache httpd.conf like:
SetEnv GEOMOOSE_LOCAL_SETTINGS '/new/path/to/setting.ini'

@theduckylittle
Copy link
Member

Yes sir.
On Dec 12, 2014 1:49 PM, "Eli L Adam" notifications@github.com wrote:

How would this be done?
Would it be in Apache httpd.conf like:
SetEnv GEOMOOSE_LOCAL_SETTINGS '/new/path/to/setting.ini'


Reply to this email directly or view it on GitHub
#59 (comment).

elil added a commit to elil/geomoose-docs that referenced this issue Dec 12, 2014
@cassiel74
Copy link
Author

Great!

@cassiel74
Copy link
Author

Finally I got it working but I believe there are few things to sort.
Let's say I define:
SetEnv GEOMOOSE_LOCAL_SETTINGS '/SOME/PATH/new_settings.ini'

new_settings.ini refers to alt_mapbook.xml

  1. c9d8ab9fcc9ba9d7a829af96a662401c90f30dff : $_ENV variables doesn't work while $_SERVER does (but maybe http://php.net/manual/en/function.apache-getenv.php would be better)
  2. 'mapfile_root' variable (as set in alt_mapbook.xml) is not taken into account while 'root' variable in 'new_settings.ini' is; so it should be pointed out somewhere that must be set.

My 0.02€
Regards

@theduckylittle
Copy link
Member

@cassiel74 - Thanks for the feedback!

Re: 1. I'll double check the docs on this before release. PHP changes its recommendations a lot and so old docs/new docs/best practice can be different. My rage against PHP continues.

Re: 2. I will add a note to the documentation about that. It would actually be better for people to specify root in the settings.ini file instead as that does not get published to the web, while the mapbook.xml contents is available in the browser.

@cassiel74
Copy link
Author

IMO the apache approach is way too restrictive when you want to deal with different "roles" (eg. I'm using drupal7 with three user roles).

If you want to serve mapbooks according to user roles (privileges) it's rather easy to set a session variable using $_SESSION or $_ENV (or apache_setenv) on the php side after a check on users privileges (eg. using drupal_bootstrap api in a php script before geomoose is served).

Doing this on the apache side requires that you define a virtual host for every role (SetEnv is invalid in <location> directive).
But then, how can you check user role and serve different mapbooks?
You could check the role, use SetEnvIf referer http://your.landing.page to be sure the request comes from your landing page, SetEnvIf some_header_variable to set the appropriate GEOMOOSE_LOCAL_SETTINGS and serve but it's quite a weak (and tricky) approach IMHO.

I know this is not 100% on topic, but worth noting.
Regards

@klassenjs
Copy link
Member

One of the initial intents of having a getmapbook.php (vs pointing to a
static file) is that it was a template that people could modify/replace
to do the "right thing" for their given environment. Examples
including: select one of many mapbooks, remove entries from a master
mapbook that the user isn't authorized for, generate a mapbook entirely
from a metadata database (or WMS server GetCapabilites or CSW server),
based on HTTP cookies, HTTP user, client IP, etc.

The HTML and JS part of GeoMoose is already agnostic about where the
mapbook comes from (either a config setting or overridable with
?mapbook= in the url). It's the other PHP scripts in the demo that
needed some way of knowing what was going on.

On 07/15/2015 04:11 AM, cassiel74 wrote:

IMO the apache approach is way too restrictive when you want to deal with different "roles" (eg. I'm using drupal7 with three user roles).

If you want to serve mapbooks according to user roles (privileges) it's rather easy to set a session variable using $_SESSION or $_ENV (or apache_setenv) on the php side after a check on users privileges (eg. using drupal_bootstrap api in a php script before geomoose is served).

Doing this on the apache side requires that you define a virtual host for every role (SetEnv is invalid in <location> directive).
But then, how can you check user role and serve different mapbooks?
You could check the role, use SetEnvIf referer http://your.landing.page to be sure the request comes from your landing page, SetEnvIf some_header_variable to set the appropriate GEOMOOSE_LOCAL_SETTINGS and serve but it's quite a weak (and tricky) approach IMHO.

I know this is not 100% on topic, but worth noting.
Regards


Reply to this email directly or view it on GitHub:
#59 (comment)

@theduckylittle
Copy link
Member

Hunh, I could've sworn I've used SetEnv on Locations before but reviewing the Apache docs show I may have just been doing it on a Directory.

That said, @klassenjs is right that the PHP scripts are really meant to be starting points and that people with more heavily customized environment can either pick-and-choose code from them or ignore them all together. FWIW, I've done GeoMOOSE installs based on Django and @klassenjs has a Perl/Ruby heavy environment that he manages.

RFC-5 and some subsequent funding has me tasked with making the query side of scripts more modular on the PHP side of things. With the running theory that people could include GeoMOOSE PHP code in their own code base more like a library and less like a stand-alone application.

On potential solution would be to write a custom "getMapbook()" in config.php (or some your preferred method of sane code management) that reads the Drupal environment. This would make getmapbook.php return the right values and fit right in with all of the other PHP scripts as they use that function to determine which mapbook to use.

BEWARE YE, thare be dragons in those waters, as it makes upgrading a bit more difficult. I'm going to keep this ticket closed but when we meet about 2.8.1/2.9 plans I'll keep all of this in mind.

@cassiel74
Copy link
Author

I understood your point, BTW Geomoose 2.8.0 still uses $_ENV in config.php

65      if(isset($_ENV['GEOMOOSE_LOCAL_SETTINGS'])) {
66          $local_settings = $_ENV['GEOMOOSE_LOCAL_SETTINGS'];

which won't work (at least here, Debian box PHP 5.6.11, Apache 2.4.12)

@tchaddad
Copy link
Contributor

@cassiel74 this is a separate question, but I'm curious if you have any trouble running GeoMoose with PHP 5.6.x? Did you compile PHP Mapscript for PHP 5.6.x?

@cassiel74
Copy link
Author

@tchaddad no problem, I use debian packages for both PHP and Mapscript, here follows exact debian release version
php5 5.6.11+dfsg-1
php5-mapscript 6.4.2-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants