diff --git a/.env.example b/.env.example index 697dfcb40..4fec67ed8 100644 --- a/.env.example +++ b/.env.example @@ -96,6 +96,9 @@ FEDERATION_LABEL=Federation host 1 # Sync settings - paging and sync delay FEDERATION_SYNC_STRUCTURE_MONITOR_INTERVAL=2m -FEDERATION_SYNC_STRUCTURE_PAGE_SIZE=100 FEDERATION_SYNC_DATA_MONITOR_INTERVAL=60s FEDERATION_SYNC_DATA_PAGE_SIZE=100 + +# This needs to be one per page for architectural reasons for now +FEDERATION_SYNC_STRUCTURE_PAGE_SIZE=1 + diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index c412868d7..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: "3" -services: - pg: - image: postgres:12.4 - environment: - - POSTGRES_PASSWORD=docker - - POSTGRES_USER=docker - ports: - - 5432:5432 - volumes: - - ./data/pg:/var/lib/postgresql/data - db: - image: percona:8.0 - restart: on-failure - environment: - # To be picked up by percona image when creating the database - # Must match with DB_DSN settings inside .env - MYSQL_DATABASE: corteza - MYSQL_USER: corteza - MYSQL_PASSWORD: rootcorteza - MYSQL_ROOT_PASSWORD: rootcorteza - volumes: [ "./data/db:/var/lib/mysql" ] # use local fs - ports: - - 3306:3306 diff --git a/federation/README.adoc b/federation/README.adoc index 53f9f5969..759b0dd1e 100644 --- a/federation/README.adoc +++ b/federation/README.adoc @@ -20,87 +20,3 @@ $ docker-compose -f federation/etc/docker-compose.yml up -d node_origin $ docker-compose -f federation/etc/docker-compose.yml up -d node_destination ---- -== Setup db (postgres) - -Add db dsn to .env -[source,bash] ----- -DB_DSN=postgres+debug://docker:docker@localhost:5432/corteza?sslmode=disable ----- - -Start the postgres db -[source,bash] ----- -$ docker-compose up -db pg ----- - -== Status - -=== Node pairing - -=== Structure sync - -.TODO -* [ ] Finish endpoints below -* [ ] Add structure sync service (the syncing process) -* [ ] Handle acl - -.List of endpoints -* [x] Show exposed module -* [x] Remove exposed module -* [x] Shared module details -* [x] List of shared/exposed modules -* [ ] Add module as exposed - same as add module to federation -* [ ] Add mappings to module -* [ ] Show module mappings -* [ ] Update fields on exposed module - - -Show exposed module:: -[source,bash] ----- -$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed" ----- - -Remove exposed module:: -[source,bash] ----- -$ curl -X DELETE "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed" ----- - -Shared module details:: -[source,bash] ----- -$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/shared" ----- - -List of shared/exposed modules:: -[source,bash] ----- -$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules?exposed=1" -$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules?shared=1" ----- - -Add module as exposed - same as add module to federation:: -[source,bash] ----- -curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules" ----- - -Add mappings to module:: -[source,bash] ----- -curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/mapped" ----- - -Show module mappings:: -[source,bash] ----- -curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/mapped" ----- - -Update fields on exposed module:: -[source,bash] ----- -curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed" ----- diff --git a/federation/rest/middleware.go b/federation/rest/middleware.go index 6c2923a0b..9330f6d18 100644 --- a/federation/rest/middleware.go +++ b/federation/rest/middleware.go @@ -2,14 +2,16 @@ package rest import ( "net/http" + + "github.com/cortezaproject/corteza-server/federation/service" ) func middlewareAllowedAccess(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - //if !service.DefaultAccessControl.CanAccess(r.Context()) { - // http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) - // return - //} + if !service.DefaultAccessControl.CanAccess(r.Context()) { + http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) + return + } next.ServeHTTP(w, r) })