[Zoo-discuss] ZOO-client and ZOO-API : concepts and usage

Fenoy Gerald gerald.fenoy at geolabs.fr
Fri Jun 10 05:39:33 PDT 2016


Rakesh,


> Le 10 juin 2016 à 13:14, rakesh prithiviraj <rakeshuk at outlook.com> a écrit :
> 
> Thanks Gerald for your quick response. 
> 
> Let me explain my use case in detail:  A user will log in to our web portal and then can execute a WPS processing service. All the processors/algorithms/Zoo service  are executed in Aysnc mode and all the processors create some directories (input dir and output directories)  on file system as part of the processing. 
> 
> The user has a unique ID and we manage a database with a table that captures user activity. Basically this table looks like below (column headers are separated by \\ )
> 
> user id \\  job id \\ job status \\ input dir \\ output dir
> 
> Note that WPS Execute request does not have input field for "user id". If I let the front end ZOO-Client talk directly to ZOO-kernel, I cannot access the user id. But by having a middle layer between front end and ZOO-kernel, I can forward used id  (and other information) from the front end to back end which can then submit the WPS execute request to ZOO-kernel and also can update the database.    

This is the same use case as in many web applications, authenticating users and storing userid (or any other information) can be done by using cookie. The cookie can obviously be passed through WPS execute request by using Header and Body blocks in the Reference definition (so it can be passed in both an XML POST request and a request sent by ZOO-API, this still have be handled by the developper). You can find more details about the way you can define a cookie from a ZOO-Service code here [1]. Once you have created an identifier for your cookie, you can store all the informations you want to share between services in the [senv] section you can allocate dynamically. It is in this section that you should add the userid you want to make accessible from every services.

> 
> I know the above reasoning may not be true because when I try to run "manage-users.GetUsers" service as described by http://zoo-project.org/cgi-bin/zoo_loader1.cgi?request=execute&service=WPS&version=2.0.0&identifier=manage-users.GetUsers , I got the exception saying "Unable to run the Service. The message returned back by the Service was the following: User not authenticated". I believe that ZOO-kernel relies on certain field in the HTTP(S) header (e.g. cookie) and accepts or rejects the execution request.

In this case it is a MapMint service, so it supposes that the user have been authenticated to access this ressource. Note that still, the service has been run, but it detected that the user was not authenticated. It means that you have to deal with your authorization inside your ZOO-Service code and do not expect the ZOO-Kernel to do any specific filtering for you. The only thing it can help with is at creating cookies and storing the key value pairs you need on the server side and reload every time the client request using this produced cookie.

> 
> One thing I couldn't figure out is how to relate the directories created by the processor/service with the Job ID so that the database can be updated.


You may take a look into the [lenv] section at runtime, it contains runtime informations. See here [2] or here [3] for more details about the values included.

I just dumped the [lenv] section from the longProcess service and got the following result when running asynchronously:

MAP => [lenv] 
Identifier: longProcess
oIdentifier: longProcess
osid: 1466500778
sid: 38934
uusid: E9220B58-2F06-11E6-A69A-000C6C07034C
usid: E9220B58-2F06-11E6-A69A-000C6C07034C
status: 60
cwd: /Users/djay/Sites/progede2/mapmint-services/test01
message: Step 60
soap: false

We may add anything more requested here.

Hope this helps.

Best regards,

[1] http://zoo-project.org/docs/kernel/configuration.html#senv-section
[2] http://zoo-project.org/docs/kernel/configuration.html#lenv-section
[3] http://zoo-project.org/doxygen/zoo__service__loader_8c.html#ac28aefcb8e972ec345696f9bf8d8001a


Gérald Fenoy
http://wiki.osgeo.org/wiki/User:Djay



More information about the Zoo-discuss mailing list