diff --git a/pg/crankshaft--0.0.1.sql b/pg/crankshaft--0.0.1.sql index cf14f86..436beea 100644 --- a/pg/crankshaft--0.0.1.sql +++ b/pg/crankshaft--0.0.1.sql @@ -1,3 +1,6 @@ +--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES +-- Complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION crankshaft" to load this file. \quit -- Internal function. -- Set the seeds of the RNGs (Random Number Generators) -- used internally. @@ -133,4 +136,13 @@ BEGIN RETURN ST_Collect(points); END; $$ -LANGUAGE plpgsql VOLATILE +LANGUAGE plpgsql VOLATILE; +-- Make sure by default there are no permissions for publicuser +-- NOTE: this happens at extension creation time, as part of an implicit transaction. +-- REVOKE ALL PRIVILEGES ON SCHEMA cdb_crankshaft FROM PUBLIC, publicuser CASCADE; + +-- Grant permissions on the schema to publicuser (but just the schema) +GRANT USAGE ON SCHEMA cdb_crankshaft TO publicuser; + +-- Revoke execute permissions on all functions in the schema by default +-- REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_crankshaft FROM PUBLIC, publicuser; diff --git a/pg/sql/0.0.1/90_permissions.sql b/pg/sql/0.0.1/90_permissions.sql new file mode 100644 index 0000000..43b1b6b --- /dev/null +++ b/pg/sql/0.0.1/90_permissions.sql @@ -0,0 +1,9 @@ +-- Make sure by default there are no permissions for publicuser +-- NOTE: this happens at extension creation time, as part of an implicit transaction. +-- REVOKE ALL PRIVILEGES ON SCHEMA cdb_crankshaft FROM PUBLIC, publicuser CASCADE; + +-- Grant permissions on the schema to publicuser (but just the schema) +GRANT USAGE ON SCHEMA cdb_crankshaft TO publicuser; + +-- Revoke execute permissions on all functions in the schema by default +-- REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_crankshaft FROM PUBLIC, publicuser; diff --git a/pg/test/0.0.1/sql/90_permissions.sql b/pg/test/0.0.1/sql/90_permissions.sql new file mode 100644 index 0000000..2e7a89c --- /dev/null +++ b/pg/test/0.0.1/sql/90_permissions.sql @@ -0,0 +1,18 @@ +SELECT cdb_crankshaft._cdb_random_seeds(1234); + +-- Use regular user role +SET ROLE test_regular_user; + +-- Add to the search path the schema +SET search_path TO public,cartodb,cdb_crankshaft; + +-- Exercise public functions +SELECT ppoints.code, m.quads + FROM ppoints + JOIN cdb_moran_local('ppoints', 'value') m + ON ppoints.cartodb_id = m.ids + ORDER BY ppoints.code; +SELECT round(cdb_overlap_sum( + '0106000020E61000000100000001030000000100000004000000FFFFFFFFFF3604C09A0B9ECEC42E444000000000C060FBBF30C7FD70E01D44400000000040AD02C06481F1C8CD034440FFFFFFFFFF3604C09A0B9ECEC42E4440'::geometry, + 'values', 'value' +), 2);