[mapserver-dev] Is there a way to use REMOTE_USER environment variable in RunTime Substitution?

Eichner, Andreas - SID Andreas.Eichner at sid.sachsen.de
Mon Dec 22 06:42:41 PST 2014


Since you store the username in the cookie you are probably not concerned about security. In this case it might be sufficient to append the username by rewriting the query string:

RewriteRule ^/my/map /my/map?user=%{REMOTE_USER} [QSA,PT]

The loadParams() in cgiutil.c only works on the QUERY_STRING and COOKIE. If you like you can insert at line 267:

if ((s = getenv2("REMOTE_USER", thread_context)) != NULL) {
	if(m >= maxParams) {
		maxParams *= 2;
		request->ParamNames = (char **) msSmallRealloc(request->ParamNames,sizeof(char *) * maxParams);
		request->ParamValues = (char **) msSmallRealloc(request->ParamValues,sizeof(char *) * maxParams);
	}
	request->ParamNames[m] = msStrdup("remote_user");
	request->ParamValues[m] = msStrdup(s);
	m++;
}

I haven't tested this but since it's pretty straight forward it should work. But that's not very generic. Probably the MAP.WEB.METADATA could be used to define a "import_env_vars"-key with a list of names to be imported from the environment...

HTH

> -----Ursprüngliche Nachricht-----
> Von: mapserver-dev-bounces at lists.osgeo.org [mailto:mapserver-dev-
> bounces at lists.osgeo.org] Im Auftrag von Smith, Michael ERDC-RDE-CRREL-NH
> Gesendet: Samstag, 20. Dezember 2014 14:25
> An: mapserver-users at lists.osgeo.org
> Cc: mapserver-dev at lists.osgeo.org
> Betreff: [mapserver-dev] Is there a way to use REMOTE_USER environment
> variable in RunTime Substitution?
> 
> I'm using apache basic auth to filter results. I have been able to use
> mod_rewrite to create a cookie with the authenticated username and use
> that in runtime subst but it would be much simpler and cleaner to just do
> it reading the environment variable. So far, I haven't found a way to do
> this in current master. Any ideas?
> 
> --
> Michael Smith
> US Army Corps
> Remote Sensing GIS/Center


More information about the mapserver-dev mailing list