Skip to content

Commit

Permalink
Add support for filtering jobs per user_id
Browse files Browse the repository at this point in the history
Add support for chaining from the OGC API - Processes - Part3: Workflows and Chaining draft specification

Add the JWT parser from the OGC Workshop within the source tree

Add missing headers

Fix typo in service_providers.rst
  • Loading branch information
gfenoy committed May 22, 2023
1 parent 5422b72 commit aa5b874
Show file tree
Hide file tree
Showing 22 changed files with 496 additions and 84 deletions.
13 changes: 7 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ services:
- ./zoo-project/zoo-services/echo-py/cgi-env/echo_service.py:/usr/lib/cgi-bin/echo_service.py
- ./zoo-project/zoo-services/echo-py/cgi-env/echo.zcfg:/usr/lib/cgi-bin/echo.zcfg
# Uncomment below to expose a process named org.n52.javaps.test.EchoProcess
# - ./zoo-project/zoo-services/echo-py/:/usr/lib/cgi-bin/org/n52/javaps/test
#- ./zoo-project/zoo-services/echo-py/cgi-env:/usr/lib/cgi-bin/org/n52/javaps/test
- ./zoo-project/zoo-services/echo-py/cgi-env/echo_service.py:/usr/lib/cgi-bin/echo_service.py
- ./zoo-project/zoo-services/echo-py/cgi-env/echo.zcfg:/usr/lib/cgi-bin/echo.zcfg
- ./zoo-project/zoo-services/utils/open-api/server/publish.py:/usr/lib/cgi-bin/publish.py
- ./zoo-project/zoo-services/utils/open-api/server/subscriber.py:/usr/lib/cgi-bin/subscriber.py
- ./docker/mapserver.conf:/mapserver/etc/mapserver.conf
Expand All @@ -37,6 +39,10 @@ services:
- ./docker/tmp:/tmp/zTmp
- ./docker/mapserver.conf:/mapserver/etc/mapserver.conf
- ./docker/com:/usr/com/zoo-project
# Uncomment below to expose a process named org.n52.javaps.test.EchoProcess
#- ./zoo-project/zoo-services/echo-py/cgi-env:/usr/lib/cgi-bin/org/n52/javaps/test
- ./zoo-project/zoo-services/echo-py/cgi-env/echo_service.py:/usr/lib/cgi-bin/echo_service.py
- ./zoo-project/zoo-services/echo-py/cgi-env/echo.zcfg:/usr/lib/cgi-bin/echo.zcfg
depends_on:
- rabbitmq
- pgbouncer
Expand Down Expand Up @@ -79,8 +85,6 @@ services:
MAX_DB_CONNECTIONS: 100
DEFAULT_POOL_SIZE: 100
POOL_MODE: transaction
ports:
- "5432:5432"
depends_on:
- pg
redis:
Expand All @@ -89,6 +93,3 @@ services:
image: rabbitmq:3.8.9-management-alpine
volumes:
- ./docker/definitions.json:/etc/rabbitmq/definitions.json
ports:
- "15672:15672"
- "5672:5672"
1 change: 1 addition & 0 deletions docker/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
AllowEncodedSlashes On

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
release = '1.9.0'
license = 'This work is released under a Creative Commons Attribution-ShareAlike 4.0 International Public License'
authors = 'ZOO-Project team'
copyright = '2009-2023, ' + authors+ '. '+ license
copyright = '2009-2022, ' + authors+ '. '+ license
show_authors = True

# Options for HTML output
Expand Down
7 changes: 4 additions & 3 deletions docs/contribute/service_providers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ please feel free to `add yourself to the service provider list <https://github.c

.. raw:: html

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
// Randomize logos
$.fn.randomize = function(selector){
Expand Down Expand Up @@ -113,6 +114,6 @@ please feel free to `add yourself to the service provider list <https://github.c
return this;
};
$('#service-provider').randomize('div.service-providers');
$("<div />", {class:"clearer"}).insertAfter('#service-provider .service-providers');
</script>
$('#service-providers').randomize('div.service-provider');
$("<div />", {class:"clearer"}).insertAfter('#service-providers .service-provider');
</script>
9 changes: 9 additions & 0 deletions zoo-project/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
Version 2.0.0
* Add JWT parser in security_service.py as filter_in to allocate
resources per authenticated user
* Update support to filter the job list using the user_id
* Add support for nested processes n OGC API - Processes - Part 3:
Workflows & Chaining
* Add filter_in and filter_out service array to be invoked previously
of andd after the service run
* Add trivial support for OpenAPI security, basicAuth / openId, add
sample services implementation
* Add support for MapServer 8.0 (actually 7.7-dev) including
returning result as OGC API -Features
* Integrate downloading MapServer 8.0 and building from the
Expand Down
72 changes: 61 additions & 11 deletions zoo-project/zoo-kernel/caching.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ char* isInCache(maps* conf,char* request){
map* tmpM=getMapFromMaps(conf,"main","cacheDir");
if(tmpM==NULL)
tmpM=getMapFromMaps(conf,"main","tmpPath");
if(strstr(request,tmpUrl->value)!=NULL){
if(tmpUrl!=NULL && strstr(request,tmpUrl->value)!=NULL){
map* tmpPath=getMapFromMaps(conf,"main","tmpPath");
char* tmpStr=strstr(request,tmpUrl->value);
char* tmpStr1=zStrdup(tmpStr+strlen(tmpUrl->value));
Expand Down Expand Up @@ -535,19 +535,20 @@ int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** er
memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
}else
addToMap((*in)->content,ufile,"true");
bool bCodes=true;
bool bCodes=false;
map* pmCodes=getMapFromMaps(*m,"main","extra_supported_codes");
if(pmCodes!=NULL){
char* pcaTmp=zStrdup(pmCodes->value);
char *pcSavePtr, *pcToken;
pcToken=strtok_r(pcaTmp,",",&pcSavePtr);
while(pcToken!=NULL){
bCodes=(hInternet->ihandle[*index].code!=atoi(pcToken));
if(!bCodes)
bCodes=(hInternet->ihandle[*index].code==atoi(pcToken));
if(bCodes)
break;
pcToken=strtok_r(NULL,",",&pcSavePtr);
}
}
}else
bCodes=true;
if(hInternet->ihandle[*index].code!=200 && bCodes){
const char *error_rep_str=_("Unable to download the file for the input <%s>, response code was : %d.");
char *error_msg=(char*)malloc((strlen(error_rep_str)+strlen(content->name)+4)*sizeof(char));
Expand Down Expand Up @@ -585,7 +586,8 @@ int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** er
sprintf(tmpStr,"%s%s",tmpStr2,tmp2->value);
free(tmpStr2);
}
md5str=getMd5(tmpStr);
char *myRequest=getFilenameForRequest(*m,tmpStr);
md5str=getMd5(myRequest);
request=zStrdup(tmpStr);
free(tmpStr);
}else{
Expand Down Expand Up @@ -669,8 +671,9 @@ int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet,map** error){
*/
void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){
hInternet->waitingRequests[hInternet->nb]=zStrdup(url);
if(req)
if(req){
InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0,*m);
}
maps *oreq=getMaps(*m,"orequests");
if(oreq==NULL){
oreq=createMaps("orequests");
Expand All @@ -694,7 +697,35 @@ void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){
*/
int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){
char* fcontent = NULL;
char* cached=isInCache(*m,url);
maps* pmsRequests=getMaps(*m,"http_requests");
char *pcUrl=NULL;
if(pmsRequests!=NULL){
map* pmLength=getMap(pmsRequests->content,"length");
int iLen=1;
if(pmLength!=NULL)
iLen=atoi(pmLength->value);
for(int iI=0;iI<iLen;iI++){
map *pmUrl=getMapArray(pmsRequests->content,"url",iI);
map *pmBody=getMapArray(pmsRequests->content,"body",iI);
map *pmHeaders=getMapArray(pmsRequests->content,"headers",iI);
if(pmUrl!=NULL && pmBody!=NULL && strcasecmp(pmUrl->value,url)==0){
if(pmHeaders!=NULL){
pcUrl=(char*)malloc((strlen(url)+strlen(pmBody->value)+strlen(pmHeaders->value)+1)*sizeof(char));
sprintf(pcUrl,"%s%s%s",url,pmBody->value,pmHeaders->value);
}
else{
pcUrl=(char*)malloc((strlen(url)+strlen(pmBody->value)+1)*sizeof(char));
sprintf(pcUrl,"%s%s",url,pmBody->value);
}
}else{
if(iI+1>=iLen)
pcUrl=zStrdup(url);
}
}
}else
pcUrl=zStrdup(url);
char* cached=isInCache(*m,pcUrl);
free(pcUrl);
char *mimeType=NULL;
char *origin=NULL;
long long fsize=0;
Expand Down Expand Up @@ -762,8 +793,25 @@ int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){
}
}
}
}else{
addRequestToQueue(m,hInternet,url,true);
}else{

if(pmsRequests!=NULL){
map* pmBody=getMapArray(pmsRequests->content,"body",hInternet->nb);
if(pmBody!=NULL){
addRequestToQueue(m,hInternet,url,false);
map* pmHeaders=getMapArray(pmsRequests->content,"Headers",hInternet->nb);
if(pmHeaders!=NULL){
hInternet->ihandle[hInternet->nb].header = NULL;
hInternet->ihandle[hInternet->nb].header =
curl_slist_append (hInternet->ihandle[hInternet->nb].header,
pmHeaders->value);
}
HINTERNET res = InternetOpenUrl(hInternet,url,pmBody->value,strlen(pmBody->value),INTERNET_FLAG_NO_CACHE_WRITE,0,*m);
addIntToMap (pmsRequests->content, "Order", hInternet->nb);
}else
addRequestToQueue(m,hInternet,url,true);
}else
addRequestToQueue(m,hInternet,url,true);
return 0;
}
if(fsize==0){
Expand All @@ -785,8 +833,10 @@ int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){
if(cached==NULL){
if(memUse==NULL || strcasecmp(memUse->value,"load")==0)
addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0);
else
else{
cacheFile(*m,url,mimeType,fsize,hInternet->ihandle[hInternet->nb-1].filename);
addToMap(*content,"cache_file",hInternet->ihandle[hInternet->nb-1].filename);
}
}
else{
addToMap(*content,"isCached","true");
Expand Down
5 changes: 0 additions & 5 deletions zoo-project/zoo-kernel/main_conf_read.y
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ miscetoile
: {}
;

Attributeetoile
: Attributeetoile {}
| {/* Epsilon */}
;

contentetoile
: contentetoile NEWLINE {}
| contentetoile pair {}
Expand Down
23 changes: 23 additions & 0 deletions zoo-project/zoo-kernel/mimetypes.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* Author : Knut LANDMARK
*
* Copyright 2015-2023 GeoLabs SARL. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "service.h"

typedef enum MimeTypes {
Expand Down
12 changes: 12 additions & 0 deletions zoo-project/zoo-kernel/request_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,12 @@ int parseInputHttpRequests(maps* conf,maps* inputs, HINTERNET* hInternet){
for(int i=0;i<llen;i++){
map* body=getMapArray(curs->content,"Body",i);
if(body!=NULL){
map* pmHeaders=getMap(curs->content,"Headers");
if(pmHeaders!=NULL){
// TODO: handle multiple headers with , as separator
hInternet->ihandle[iCnt].header =
curl_slist_append (hInternet->ihandle[iCnt].header,pmHeaders->value);
}
addRequestToQueue(&conf,hInternet,(char *) href->value,false);
InternetOpenUrl (hInternet,
href->value,
Expand All @@ -2111,6 +2117,12 @@ int parseInputHttpRequests(maps* conf,maps* inputs, HINTERNET* hInternet){
}else{
map* body=getMap(curs->content,"Body");
if(body!=NULL){
map* pmHeaders=getMap(curs->content,"Headers");
if(pmHeaders!=NULL){
// TODO: handle multiple headers with , as separator
hInternet->ihandle[iCnt].header =
curl_slist_append (hInternet->ihandle[iCnt].header,pmHeaders->value);
}
addRequestToQueue(&conf,hInternet,(char *) href->value,false);
InternetOpenUrl (hInternet,
href->value,
Expand Down
15 changes: 8 additions & 7 deletions zoo-project/zoo-kernel/response_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -2339,19 +2339,19 @@ void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xml
map *tmpMap=getMap(m->content,"Reference");
if(tmpMap==NULL){
nc2=xmlNewNode(ns_wps, BAD_CAST "Data");
if(e!=NULL && e->format!=NULL){
if (strncasecmp(e->format, "LiteralOutput", strlen(e->format)) == 0)
nc3 = xmlNewNode(ns_wps, BAD_CAST "LiteralData");
if(e!=NULL && e->format!=NULL){
if (strncasecmp(e->format, "LiteralOutput", strlen(e->format)) == 0)
nc3 = xmlNewNode(ns_wps, BAD_CAST "LiteralData");
else
if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0)
nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData");
else if(strncasecmp(e->format,"BoundingBoxOutput",strlen(e->format))==0)
nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData");
else
nc3=xmlNewNode(ns_wps, BAD_CAST e->format);
nc3=xmlNewNode(ns_wps, BAD_CAST e->format);
}
else {
map* tmpV=getMapFromMaps(m,"format","value");
map* tmpV=getMapFromMaps(m,"format","value");
if(tmpV!=NULL)
nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value);
else
Expand Down Expand Up @@ -2389,7 +2389,7 @@ void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xml
free(tmpRes);
}
}
else {
else {
//if (e != NULL) {
if (e != NULL && e->defaults != NULL) { // knut: add extra NULL pointer check in case user omits <Default> block in config file
tmp = getMap(e->defaults->content, "mimeType");
Expand Down Expand Up @@ -2468,7 +2468,8 @@ void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xml
else // else
xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); // add text node
}
xmlAddChild(nc2,nc3);
if(vid==0)
xmlAddChild(nc2,nc3);
}
else {
xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value));
Expand Down
3 changes: 2 additions & 1 deletion zoo-project/zoo-kernel/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,8 @@ maps* dupMaps(maps** ppmsOut){
if(pmsChild!=NULL){
pmRes->child=dupMaps(&pmsChild);
}
pmRes->next=dupMaps(&pmsCursor->next);
if(pmsCursor->next!=NULL)
pmRes->next=dupMaps(&pmsCursor->next);
}
return pmRes;
}
Expand Down
5 changes: 5 additions & 0 deletions zoo-project/zoo-kernel/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ extern "C" {
*/
#define SERVICE_DISMISSED 5

/**
* The ZOO_DEBUG macro print message with function name, file name and line number
*/
#define ZOO_DEBUG(message) fprintf(stderr," [ZOO_DEBUG] ++----++ %s %s %d: ",__func__,__FILE__,__LINE__);fprintf(stderr,"(%s)\n",message);

/**
* The memory size to create an elements
*/
Expand Down

0 comments on commit aa5b874

Please sign in to comment.