Delegate user permission to PostgreSQL (closes #18)

If the request is authenticated (with map_key) then we log as the
database owner, otherwise we log as the default user.
The default user is now "publicuser" by default.

Raises dependency on Windshaft to 0.4.9+, to get the grainstore
version allowing override of database username.

Add test for req2params function, particularly authentication,
Add test for authenticated / unauthenticated access
This commit is contained in:
Sandro Santilli
2012-07-18 11:09:17 +02:00
parent c918b09e64
commit de275bfc50
13 changed files with 150 additions and 36 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ CREATE TABLE gadm4 (
);
GRANT ALL ON TABLE gadm4 TO postgres;
GRANT ALL ON TABLE gadm4 TO tileuser;
GRANT ALL ON TABLE gadm4 TO publicuser;
CREATE SEQUENCE gadm4_seq
START WITH 1
INCREMENT BY 1
@@ -100,5 +100,5 @@ CREATE INDEX bdll25_provincias_4326_2_the_geom_webmercator_idx ON gadm4 USING gi
-- development_cartodb_user_3 role
CREATE USER development_cartodb_user_3;
GRANT ALL ON TABLE gadm4 TO development_cartodb_user_3;
GRANT SELECT ON TABLE gadm4 TO tileuser;
GRANT SELECT ON TABLE gadm4 TO publicuser;
+30 -7
View File
@@ -15,8 +15,11 @@ SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
-- tileuser role
CREATE USER tileuser;
-- publicuser role
CREATE USER publicuser;
-- db owner role
CREATE USER test_cartodb_user_1;
-- first table
CREATE TABLE test_table (
@@ -59,8 +62,8 @@ ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (cartodb_
CREATE INDEX test_table_the_geom_idx ON test_table USING gist (the_geom);
CREATE INDEX test_table_the_geom_webmercator_idx ON test_table USING gist (the_geom_webmercator);
GRANT ALL ON TABLE test_table TO postgres;
GRANT ALL ON TABLE test_table TO tileuser;
GRANT ALL ON TABLE test_table TO test_cartodb_user_1;
GRANT SELECT ON TABLE test_table TO publicuser;
-- second table
CREATE TABLE test_table_2 (
@@ -103,7 +106,8 @@ ALTER TABLE ONLY test_table_2 ADD CONSTRAINT test_table_2_pkey PRIMARY KEY (cart
CREATE INDEX test_table_2_the_geom_idx ON test_table_2 USING gist (the_geom);
CREATE INDEX test_table_2_the_geom_webmercator_idx ON test_table_2 USING gist (the_geom_webmercator);
GRANT ALL ON TABLE test_table_2 TO tileuser;
GRANT ALL ON TABLE test_table_2 TO test_cartodb_user_1;
GRANT SELECT ON TABLE test_table_2 TO publicuser;
-- third table
CREATE TABLE test_table_3 (
@@ -146,5 +150,24 @@ ALTER TABLE ONLY test_table_3 ADD CONSTRAINT test_table_3_pkey PRIMARY KEY (cart
CREATE INDEX test_table_3_the_geom_idx ON test_table_3 USING gist (the_geom);
CREATE INDEX test_table_3_the_geom_webmercator_idx ON test_table_3 USING gist (the_geom_webmercator);
GRANT ALL ON TABLE test_table_3 TO postgres;
GRANT ALL ON TABLE test_table_3 TO tileuser;
GRANT ALL ON TABLE test_table_3 TO test_cartodb_user_1;
GRANT SELECT ON TABLE test_table_3 TO publicuser;
-- private table
CREATE TABLE test_table_private_1 (
updated_at timestamp without time zone DEFAULT now(),
created_at timestamp without time zone DEFAULT now(),
cartodb_id integer NOT NULL,
name character varying,
address character varying,
the_geom geometry,
the_geom_webmercator geometry,
CONSTRAINT enforce_dims_the_geom CHECK ((st_ndims(the_geom) = 2)),
CONSTRAINT enforce_dims_the_geom_webmercator CHECK ((st_ndims(the_geom_webmercator) = 2)),
CONSTRAINT enforce_geotype_the_geom CHECK (((geometrytype(the_geom) = 'POINT'::text) OR (the_geom IS NULL))),
CONSTRAINT enforce_geotype_the_geom_webmercator CHECK (((geometrytype(the_geom_webmercator) = 'POINT'::text) OR (the_geom_webmercator IS NULL))),
CONSTRAINT enforce_srid_the_geom CHECK ((st_srid(the_geom) = 4326)),
CONSTRAINT enforce_srid_the_geom_webmercator CHECK ((st_srid(the_geom_webmercator) = 3857))
);
GRANT ALL ON TABLE test_table_private_1 TO test_cartodb_user_1;