Added the organization public user to the api key check
This commit is contained in:
parent
dda83c0976
commit
06f033b72a
@ -33,4 +33,4 @@ CREATE SCHEMA cdb_geocoder_server;
|
|||||||
DROP ROLE IF EXISTS test_regular_user;
|
DROP ROLE IF EXISTS test_regular_user;
|
||||||
CREATE ROLE test_regular_user;
|
CREATE ROLE test_regular_user;
|
||||||
GRANT publicuser TO test_regular_user;
|
GRANT publicuser TO test_regular_user;
|
||||||
ALTER ROLE test_regular_user SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
ALTER ROLE test_regular_user SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
-- Mock the server function
|
-- Mock the server function
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Use regular user role
|
-- Use regular user role
|
||||||
SET ROLE test_regular_user;
|
SET ROLE test_regular_user;
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
-- Exercise the public function
|
-- Exercise the public function
|
||||||
-- it is public, it shall work
|
-- it is public, it shall work
|
||||||
SELECT cdb_geocode_admin0_polygon('Spain');
|
SELECT cdb_geocode_admin0_polygon('Spain');
|
||||||
|
@ -22,4 +22,4 @@ CREATE SCHEMA cdb_geocoder_server;
|
|||||||
DROP ROLE IF EXISTS test_regular_user;
|
DROP ROLE IF EXISTS test_regular_user;
|
||||||
CREATE ROLE test_regular_user;
|
CREATE ROLE test_regular_user;
|
||||||
GRANT publicuser TO test_regular_user;
|
GRANT publicuser TO test_regular_user;
|
||||||
ALTER ROLE test_regular_user SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
ALTER ROLE test_regular_user SET search_path TO public,cartodb,cdb_geocoder_client;
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
|
|
||||||
-- Mock the server function
|
-- Mock the server function
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
|
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
|
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
|
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
|
|
||||||
-- Mock the server functions
|
-- Mock the server functions
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
SET ROLE test_regular_user;
|
SET ROLE test_regular_user;
|
||||||
|
|
||||||
-- Add to the search path the schema
|
-- Add to the search path the schema
|
||||||
SET search_path TO "$user",public,cartodb,cdb_geocoder_client;
|
SET search_path TO public,cartodb,cdb_geocoder_client;
|
||||||
|
|
||||||
-- Exercise the public function
|
-- Exercise the public function
|
||||||
-- it is public, it shall work
|
-- it is public, it shall work
|
||||||
|
@ -11,7 +11,7 @@ DECLARE
|
|||||||
user_config json;
|
user_config json;
|
||||||
geocoder_config json;
|
geocoder_config json;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF session_user = 'publicuser' THEN
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
RAISE EXCEPTION 'The api_key must be provided';
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
END IF;
|
END IF;
|
||||||
SELECT cartodb.CDB_Conf_GetConf('<%= user_config_key %>') INTO user_config;
|
SELECT cartodb.CDB_Conf_GetConf('<%= user_config_key %>') INTO user_config;
|
||||||
|
Loading…
Reference in New Issue
Block a user