2019-02-20 21:45:57 +08:00
|
|
|
SELECT session_user; -- postgres
|
2019-02-20 17:38:00 +08:00
|
|
|
SELECT CDB_Username(); -- (NULL)
|
|
|
|
|
2019-02-20 21:45:57 +08:00
|
|
|
-- Add the role fulano with api_key and connect with it
|
2019-02-20 17:38:00 +08:00
|
|
|
\set QUIET on
|
2019-02-20 20:34:11 +08:00
|
|
|
CREATE ROLE fulano LOGIN;
|
|
|
|
GRANT USAGE ON SCHEMA cartodb TO fulano;
|
|
|
|
GRANT EXECUTE ON FUNCTION CDB_Username() TO fulano;
|
|
|
|
INSERT INTO cdb_conf (key, value) VALUES ('api_keys_fulano', '{"username": "fulanito", "permissions":[]}');
|
2019-02-20 21:45:57 +08:00
|
|
|
SET SESSION AUTHORIZATION fulano;
|
2019-02-20 17:38:00 +08:00
|
|
|
\set QUIET off
|
|
|
|
|
2019-02-20 21:45:57 +08:00
|
|
|
SELECT session_user; -- fulano
|
2019-02-20 20:34:11 +08:00
|
|
|
SELECT CDB_Username(); -- fulanito
|
|
|
|
|
|
|
|
-- Remove fulano
|
|
|
|
\set QUIET on
|
2019-02-20 21:45:57 +08:00
|
|
|
SET SESSION AUTHORIZATION postgres;
|
2019-02-20 20:34:11 +08:00
|
|
|
REVOKE USAGE ON SCHEMA cartodb FROM fulano;
|
|
|
|
REVOKE EXECUTE ON FUNCTION CDB_Username() FROM fulano;
|
|
|
|
DROP ROLE fulano;
|
2019-03-08 19:03:55 +08:00
|
|
|
DELETE FROM cdb_conf WHERE key = 'api_keys_fulano';
|
2019-02-20 21:45:57 +08:00
|
|
|
\set QUIET off
|