From e5227ce6a6fccc843b82888fad82915d2f91f258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B1=BC=E7=AB=BF=E9=92=93=E9=B1=BC=E5=B9=B2?= <46661603+PokIsemaine@users.noreply.github.com> Date: Sun, 9 Jul 2023 20:57:42 +0800 Subject: [PATCH] fix: fix GitHub Action (#24) * fix: GitHub CI * fix: GitHub CI * fix: GitHub CI * fix: GitHub CI * fix: GitHub CI * fix: GitHub CI * fix: GitHub CI * fix: GitHub CI --- .github/workflows/ci.yml | 9 +++++++-- client/enforce_test.go | 3 ++- config/connection_config.json | 5 +++++ examples/rbac_model.conf | 14 ++++++++++++++ examples/rbac_policy.csv | 12 ++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 config/connection_config.json create mode 100644 examples/rbac_model.conf create mode 100644 examples/rbac_policy.csv diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50ed6cd..2ef5fe6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,13 @@ jobs: run: | set -x docker version - docker run -d -p 50051:50051 casbin/casbin-server - + docker run -id -p 50051:50051 \ + -e CONNECTION_CONFIG_PATH=/config/connection_config.json \ + -v $GITHUB_WORKSPACE/config:/config \ + -v $GITHUB_WORKSPACE/examples:/data/examples \ + --name my-casbin-server-config \ + -d casbin/casbin-server + - name: Go Test run: go test ./... diff --git a/client/enforce_test.go b/client/enforce_test.go index 8babbaa..61177bc 100644 --- a/client/enforce_test.go +++ b/client/enforce_test.go @@ -2,11 +2,12 @@ package client import ( "context" - "google.golang.org/grpc" "log" "testing" "time" + "google.golang.org/grpc" + "github.com/casbin/casbin/v2/util" ) diff --git a/config/connection_config.json b/config/connection_config.json new file mode 100644 index 0000000..704e1b9 --- /dev/null +++ b/config/connection_config.json @@ -0,0 +1,5 @@ +{ + "driver": "file", + "connection": "/data/examples/rbac_policy.csv", + "enforcer": "/data/examples/rbac_model.conf" +} \ No newline at end of file diff --git a/examples/rbac_model.conf b/examples/rbac_model.conf new file mode 100644 index 0000000..71159e3 --- /dev/null +++ b/examples/rbac_model.conf @@ -0,0 +1,14 @@ +[request_definition] +r = sub, obj, act + +[policy_definition] +p = sub, obj, act + +[role_definition] +g = _, _ + +[policy_effect] +e = some(where (p.eft == allow)) + +[matchers] +m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/examples/rbac_policy.csv b/examples/rbac_policy.csv new file mode 100644 index 0000000..ebe3635 --- /dev/null +++ b/examples/rbac_policy.csv @@ -0,0 +1,12 @@ +p, alice, data1, read +p, bob, data2, write +p, data2_admin, data2, read +p, data2_admin, data2, write + +g, alice, data2_admin + +g, george, data3_admin +g, data3_admin, data4_admin + +p, data3_admin, data3, admin +p, data4_admin, data4, read \ No newline at end of file