[ckan-pt] Dúvida para configuração DataStore

Julio Zinga Suzuki Lopes juliozinga gmail.com
Domingo, 22 de Janeiro de 2017 - 01:02:37 UTC


Olá a todos e todas,

Estou instalando o ckan no ubuntu 14.04 conforme tutorial.
Todos os softwares estão rodando na mesma máquina. Acredito que o problema
esteja sendo em relação ao usuário e permissões no banco de dados.
Obtive sucesso com o filestore. Toda via ao "chegar" no datastore, obtive
os seguintes problemas:


Consulta bem sucedida conforme tutorial
$ curl -X GET "
http://192.168.0.31/api/3/action/datastore_search?resource_id=_table_metadata
"
{"help": "http://192.168.0.31/api/3/action/help_show?name=datastore_search",
"success": true, "result": {"resource_id": "_table_metadata", "fields":
[{"type": "text", "id": "_id"}, {"type": "name", "id": "name"}, {"type":
"oid", "id": "oid"}, {"type": "name", "id": "alias_of"}], "records":
[{"_id": "1fab8662e5772995", "alias_of": "pg_views", "name":
"_table_metadata", "oid": 18109}, {"_id": "21b5fe766665b205", "alias_of":
"pg_tables", "name": "_table_metadata", "oid": 18109}], "_links": {"start":
"/api/3/action/datastore_search?resource_id=_table_metadata", "next":
"/api/3/action/datastore_search?offset=100&resource_id=_table_metadata"},
"total": 2}}


tentativa de criação do dataset no datastore através do comando curl
(tutorial)

curl -X POST http://192.168.0.31/api/3/action/datastore_create -H
"Authorization: {8195d98d-c892-428a-9d9a-ac7061f3a572}" -d '{"resource":
{"package_id": "{data1}"}, "fields": [ {"id": "a"}, {"id": "b"} ],
"records": [ { "a": 1, "b": "xyz"}, {"a": 2, "b": "zzz"} ]}'

{"help": "http://192.168.0.31/api/3/action/help_show?name=datastore_create",
"success": false, "error": {"message": "Access denied: <function
datastore_create at 0x7fa6a0072410> requires an authenticated user",
"__type": "Authorization Error"}}






alguns comandos atribuidos anteriormente


xx  server:~$ sudo ckan datastore set-permissions | sudo -u postgres psql
--set ON_ERROR_STOP=1
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "pt_BR.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
You are now connected to database "datastore_default" as user "postgres".
REVOKE
REVOKE
GRANT
GRANT
GRANT
GRANT
REVOKE
GRANT
GRANT
GRANT
ALTER DEFAULT PRIVILEGES
xx  server:~$ sudo ckan datastore set-permissions
/*
This script configures the permissions for the datastore.

It ensures that the datastore read-only user will only be able to select
from
the datastore database but has no create/write/edit permission or any
permissions on other databases. You must execute this script as a database
superuser on the PostgreSQL server that hosts your datastore database.

For example, if PostgreSQL is running locally and the "postgres" user has
the
appropriate permissions (as in the default Ubuntu PostgreSQL install), you
can
run:

    paster datastore set-permissions | sudo -u postgres psql

Or, if your PostgreSQL server is remote, you can pipe the permissions script
over SSH:

    paster datastore set-permissions | ssh dbserver sudo -u postgres psql

*/

-- Most of the following commands apply to an explicit database or to the
whole
-- 'public' schema, and could be executed anywhere. But ALTER DEFAULT
-- PERMISSIONS applies to the current database, and so we must be connected
to
-- the datastore DB:
\connect datastore_default

-- revoke permissions for the read-only user
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
REVOKE USAGE ON SCHEMA public FROM PUBLIC;

GRANT CREATE ON SCHEMA public TO "ckan_default";
GRANT USAGE ON SCHEMA public TO "ckan_default";

GRANT CREATE ON SCHEMA public TO "ckan_default";
GRANT USAGE ON SCHEMA public TO "ckan_default";

-- take connect permissions from main db
REVOKE CONNECT ON DATABASE "ckan_default" FROM "datastore_default";

-- grant select permissions for read-only user
GRANT CONNECT ON DATABASE "datastore_default" TO "datastore_default";
GRANT USAGE ON SCHEMA public TO "datastore_default";

-- grant access to current tables and views to read-only user
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "datastore_default";

-- grant access to new tables and views by default
ALTER DEFAULT PRIVILEGES FOR USER "ckan_default" IN SCHEMA public
   GRANT SELECT ON TABLES TO "datastore_default";


xx  server:~$ sudo -u postgres psql -l
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "pt_BR.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
                                             List of databases
       Name        |    Owner     | Encoding |   Collate   |    Ctype
|        Access privileges
-------------------+--------------+----------+-------------+-------------+----------------------------------
 ckan_default      | ckan_default | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
=Tc/ckan_default                +
                   |              |          |             |             |
ckan_default=CTc/ckan_default
 datastore_default | ckan_default | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
=Tc/ckan_default                +
                   |              |          |             |             |
ckan_default=CTc/ckan_default   +
                   |              |          |             |             |
datastore_default=c/ckan_default
 postgres          | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0         | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
=c/postgres                     +
                   |              |          |             |             |
postgres=CTc/postgres
 template1         | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
=c/postgres                     +
                   |              |          |             |             |
postgres=CTc/postgres
(5 rows)

-- 
-- 
Júlio Zinga Suzuki Lopes
Analista de TI
Instituto Federal da Paraíba
-------------- próxima parte ----------
Um anexo em HTML foi limpo...
URL: <http://lists.okfn.org/pipermail/ckan-pt/attachments/20170121/3fee5fbe/attachment-0002.html>


Mais informações acerca da lista ckan-pt