Oracle Layer: how to set context prior to fetching the data

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Oracle Layer: how to set context prior to fetching the data

Martin Icking
One of the Oracle based sources we are publishing is using Oracle context variables to enable Oracle's fine grained access control.
So we are in the need to set these context variables (e.g. current username) prior to doing the select defined by MapServer's DATA statement. In other applications we do that by calling a set_context (...) stored procedure prior to any data requests.
Is there any possibility in MapServer to send a pre-request statement to the database? A current work-around is to set the context at logon time but that means that we need a new logon for every request that needs a different user context, not optimal for websites with many users. We'd prefer to have a single logon that can be re-used for all requests.
If there is currently no way to handle this in MapServer we'd like to extend the Oracle layer's capabilities. Any suggestion by the MS developers on where we should place the needed extension in the mapfile (e.g. adding an additional keyword at the USING part of the data statement or using new layer metadata)?
Any interest in generalizing this approach?

Tx
Martin
Reply | Threaded
Open this post in threaded view
|

Re: Oracle Layer: how to set context prior to fetching the data

jmckenna
Administrator
Hi Martin,

Have you tried using a virtual spatial layer (.ovf) file to manage this?
  You can include a "<SrcSQL>" tag to run your stored procedure.  See
examples at http://mapserver.org/input/vector/VirtualSpatialData.html 
More details of that driver at: http://www.gdal.org/drv_vrt.html

Otherwise, I have seen others on this mailing list use stored procedures
in the DATA statement of the mapfile, such as:

DATA "the_geom from (select the_geom, id, name, myprocedure() as style
from states) as foo using srid=4326 using unique id"

Maybe the ovf is the way to go for your case, not sure.

-jeff

--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2016-03-24 6:59 AM, Martin Icking wrote:

> One of the Oracle based sources we are publishing is using Oracle context
> variables to enable Oracle's fine grained access control.
> So we are in the need to set these context variables (e.g. current username)
> prior to doing the select defined by MapServer's DATA statement. In other
> applications we do that by calling a set_context (...) stored procedure
> prior to any data requests.
> Is there any possibility in MapServer to send a pre-request statement to the
> database? A current work-around is to set the context at logon time but that
> means that we need a new logon for every request that needs a different user
> context, not optimal for websites with many users. We'd prefer to have a
> single logon that can be re-used for all requests.
> If there is currently no way to handle this in MapServer we'd like to extend
> the Oracle layer's capabilities. Any suggestion by the MS developers on
> where we should place the needed extension in the mapfile (e.g. adding an
> additional keyword at the USING part of the data statement or using new
> layer metadata)?
> Any interest in generalizing this approach?
>
> Tx
> Martin
>

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Oracle Layer: how to set context prior to fetching the data

Dan Little-2
The other option is to create yet-another stored procedure wrapper.  In the Mapfile, you'd call the special wrapper stored procedure and it would return the rows to map.

On Thu, Mar 24, 2016 at 8:16 AM, Jeff McKenna <[hidden email]> wrote:
Hi Martin,

Have you tried using a virtual spatial layer (.ovf) file to manage this?  You can include a "<SrcSQL>" tag to run your stored procedure.  See examples at http://mapserver.org/input/vector/VirtualSpatialData.html More details of that driver at: http://www.gdal.org/drv_vrt.html

Otherwise, I have seen others on this mailing list use stored procedures in the DATA statement of the mapfile, such as:

DATA "the_geom from (select the_geom, id, name, myprocedure() as style from states) as foo using srid=4326 using unique id"

Maybe the ovf is the way to go for your case, not sure.

-jeff

--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2016-03-24 6:59 AM, Martin Icking wrote:
One of the Oracle based sources we are publishing is using Oracle context
variables to enable Oracle's fine grained access control.
So we are in the need to set these context variables (e.g. current username)
prior to doing the select defined by MapServer's DATA statement. In other
applications we do that by calling a set_context (...) stored procedure
prior to any data requests.
Is there any possibility in MapServer to send a pre-request statement to the
database? A current work-around is to set the context at logon time but that
means that we need a new logon for every request that needs a different user
context, not optimal for websites with many users. We'd prefer to have a
single logon that can be re-used for all requests.
If there is currently no way to handle this in MapServer we'd like to extend
the Oracle layer's capabilities. Any suggestion by the MS developers on
where we should place the needed extension in the mapfile (e.g. adding an
additional keyword at the USING part of the data statement or using new
layer metadata)?
Any interest in generalizing this approach?

Tx
Martin


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Oracle Layer: how to set context prior to fetching the data

Michael Smith
In reply to this post by Martin Icking
Martin,

How I've done this in the past is use a plsql function that sets the
context and call that function in the query (and just have the function
return a dummy value that you don't use).

Mike

--
Michael Smith

Remote Sensing/GIS Center
US Army Corps of Engineers



On 3/24/16,  5:59 AM, "mapserver-users on behalf of Martin Icking"
<[hidden email] on behalf of
[hidden email]> wrote:

>One of the Oracle based sources we are publishing is using Oracle context
>variables to enable Oracle's fine grained access control.
>So we are in the need to set these context variables (e.g. current
>username)
>prior to doing the select defined by MapServer's DATA statement. In other
>applications we do that by calling a set_context (...) stored procedure
>prior to any data requests.
>Is there any possibility in MapServer to send a pre-request statement to
>the
>database? A current work-around is to set the context at logon time but
>that
>means that we need a new logon for every request that needs a different
>user
>context, not optimal for websites with many users. We'd prefer to have a
>single logon that can be re-used for all requests.
>If there is currently no way to handle this in MapServer we'd like to
>extend
>the Oracle layer's capabilities. Any suggestion by the MS developers on
>where we should place the needed extension in the mapfile (e.g. adding an
>additional keyword at the USING part of the data statement or using new
>layer metadata)?
>Any interest in generalizing this approach?
>
>Tx
>Martin
>
>
>
>--
>View this message in context:
>http://osgeo-org.1560.x6.nabble.com/Oracle-Layer-how-to-set-context-prior-
>to-fetching-the-data-tp5258155.html
>Sent from the Mapserver - User mailing list archive at Nabble.com.
>_______________________________________________
>mapserver-users mailing list
>[hidden email]
>http://lists.osgeo.org/mailman/listinfo/mapserver-users


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Oracle Layer: how to set context prior to fetching the data

Martin Icking
Hi Mike,
I've tried this and in principle this works but sometimes it seems to me that the context setting in the function happens AFTER the query has been executed so that only a second call to the query gives the correnct number of rows.
Any idea on how to enforce that the context setting will be the first step in the query execution?

Tx
Martin