diff --git a/server/extension/cdb_geocoder_server--0.0.1--0.1.0.sql b/server/extension/cdb_geocoder_server--0.0.1--0.1.0.sql index 43aa150..808a118 100644 --- a/server/extension/cdb_geocoder_server--0.0.1--0.1.0.sql +++ b/server/extension/cdb_geocoder_server--0.0.1--0.1.0.sql @@ -47,6 +47,7 @@ RETURNS boolean AS $$ } return True $$ LANGUAGE plpythonu; + -- Get the Redis configuration from the _conf table -- CREATE OR REPLACE FUNCTION cdb_geocoder_server._get_geocoder_config(username text, orgname text) RETURNS boolean AS $$ @@ -71,7 +72,8 @@ RETURNS boolean AS $$ # --for this user session but... GD[cache_key] = geocoder_config return True -$$ LANGUAGE plpythonu; +$$ LANGUAGE plpythonu SECURITY DEFINER; + -- Geocodes a street address given a searchtext and a state and/or country CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_street_point_v2(username TEXT, orgname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ @@ -130,3 +132,10 @@ RETURNS Geometry AS $$ plpy.error('Google geocoder is not available yet') return None $$ LANGUAGE plpythonu; + +-- We apply again the grants to include the new functions +GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_geocoder_server TO geocoder_api; +GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO geocoder_api; +GRANT USAGE ON SCHEMA cdb_geocoder_server TO geocoder_api; +GRANT USAGE ON SCHEMA public TO geocoder_api; +GRANT SELECT ON ALL TABLES IN SCHEMA public TO geocoder_api; diff --git a/server/extension/sql/0.1.0/15_config_helper.sql b/server/extension/sql/0.1.0/15_config_helper.sql index dd37953..39a8af2 100644 --- a/server/extension/sql/0.1.0/15_config_helper.sql +++ b/server/extension/sql/0.1.0/15_config_helper.sql @@ -22,4 +22,4 @@ RETURNS boolean AS $$ # --for this user session but... GD[cache_key] = geocoder_config return True -$$ LANGUAGE plpythonu; +$$ LANGUAGE plpythonu SECURITY DEFINER;