From b6d37c677309094122653b4a6da6accf47c6f545 Mon Sep 17 00:00:00 2001 From: antoniocarlon Date: Tue, 11 Sep 2018 11:07:59 +0200 Subject: [PATCH] Managing public api key permissions --- client/renderer/templates/20_public_functions.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/renderer/templates/20_public_functions.erb b/client/renderer/templates/20_public_functions.erb index a5c4fcf..309f1cb 100644 --- a/client/renderer/templates/20_public_functions.erb +++ b/client/renderer/templates/20_public_functions.erb @@ -11,9 +11,9 @@ DECLARE <%= user_org_declaration %> <% unless superuser_function? -%>apikey_permissions json;<% end %> BEGIN - IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN + <% unless requires_permission %>IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN RAISE EXCEPTION 'The api_key must be provided'; - END IF; + END IF;<% end %> <% unless superuser_function? -%>SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json); <% if requires_permission %>IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? '<%= permission_name %>' THEN RAISE EXCEPTION '<%= permission_error %>' USING ERRCODE = '01007';