openslides-permission-service

module
v0.0.0-...-4b058fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2021 License: MIT

README

Permission Service

This Repository is depricated. The code was moved into The autoupdate repository. The service is not used anymore.

The permisson service is a service and a libary for OpenSlides4 that tells, if a user can see specific content.

Build and run

With Golang
go build ./cmd/permission/ && ./permission
With Docker

The docker build uses the datastore-reader-service as default. Either configure it to use the fake services (see environment variables below) or make sure the service inside the docker container can connect to the datastore-reader. For example with the docker argument --network host.

docker build . --tag openslides-permission
docker run --network host openslides-permission
With Auto Restart

To restart the service when ever a source file has shanged, the tool CompileDaemon can help.

go get github.com/githubnemo/CompileDaemon
CompileDaemon -log-prefix=false -build "go build ./cmd/permission" -command "./permission"

The make target build-dev creates a docker image that uses this tool:

make build-dev
docker run -v $(pwd)/cert:/root/cert --network host openslides-permission-dev

Example Request

curl http://localhost:9005/internal/permission/is_allowed -d '{"name":"topic.create","user_id":1}'

Test

Only Business Logic

The business logic are the cases, when the permission case should return true or false or restrict some fqfields.

To test only the to business logic run:

tests/run.sh

If a test case fails, a message like:

FAIL: TestCases/motion/create.yml:create_amentment_with_wrong_perm (0.00s)

is shown. To test only this case, run:

tests/run.sh TestCases/motion/create.yml:create_amentment_with_wrong_perm

To see the coverage for all business logic in the browser, run:

make cover
With Golang
go test ./...
With Make

There is a make target, that creates and runs the docker-test-container:

make run-tests

Autogen actions

There are some permission routes, that are autogenerated. The list of these simple routes are fetched from the backend service.

When the list of these routes chances, the code has to be updated with

go generate ./...

Environment Variables

  • PERMISSION_HOST: Host where the http service listens to. Default is an empty string which means all devices.
  • PERMISSION_PORT: Port where the http services listens to. Default is 9005.
  • DATASTORE: Sets the datastore service. fake (default) or service.
  • DATASTORE_READER_HOST: Host of the datastore reader. The default is localhost.
  • DATASTORE_READER_PORT: Port of the datastore reader. The default is 9010.
  • DATASTORE_READER_PROTOCOL: Protocol of the datastore reader. The default is http.

Directories

Path Synopsis
cmd
internal
datastore
Package datastore connects to the datastore-reader-service.
Package datastore connects to the datastore-reader-service.
http
Package http provides HTTP handler to give other services access to to permission service.
Package http provides HTTP handler to give other services access to to permission service.
perm
Code generated with generated/main.go DO NOT EDIT.
Code generated with generated/main.go DO NOT EDIT.
tests
Code generated with models.txt DO NOT EDIT.
Code generated with models.txt DO NOT EDIT.
tests/gen_fields
This tool generates the list fields of every collection.
This tool generates the list fields of every collection.
pkg
permission
Package permission handels the permissions of a user.
Package permission handels the permissions of a user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL