{"id":45902640,"url":"https://github.com/grepplabs/casbin-kube","last_synced_at":"2026-02-28T00:11:16.247Z","repository":{"id":317758518,"uuid":"1066034231","full_name":"grepplabs/casbin-kube","owner":"grepplabs","description":"Kubernetes adapter for Casbin","archived":false,"fork":false,"pushed_at":"2026-02-16T09:55:00.000Z","size":162,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-16T17:58:35.890Z","etag":null,"topics":["access-control","acl","auth","authz","autorization","casbin","casbin-adapter","crd","gitops","k8s","kubernetes","rbac"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grepplabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-28T23:08:31.000Z","updated_at":"2026-02-16T09:54:04.000Z","dependencies_parsed_at":"2025-10-06T07:30:59.478Z","dependency_job_id":null,"html_url":"https://github.com/grepplabs/casbin-kube","commit_stats":null,"previous_names":["grepplabs/casbin-kube"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/grepplabs/casbin-kube","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grepplabs%2Fcasbin-kube","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grepplabs%2Fcasbin-kube/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grepplabs%2Fcasbin-kube/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grepplabs%2Fcasbin-kube/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grepplabs","download_url":"https://codeload.github.com/grepplabs/casbin-kube/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grepplabs%2Fcasbin-kube/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29920568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"ssl_error","status_checked_at":"2026-02-27T19:37:41.463Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access-control","acl","auth","authz","autorization","casbin","casbin-adapter","crd","gitops","k8s","kubernetes","rbac"],"created_at":"2026-02-28T00:11:15.808Z","updated_at":"2026-02-28T00:11:16.227Z","avatar_url":"https://github.com/grepplabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Casbin Kube\n====\n\n[![Build](https://github.com/grepplabs/casbin-kube/actions/workflows/ci.yml/badge.svg)](https://github.com/grepplabs/casbin-kube/actions/workflows/ci.yml)\n[![Godoc](https://godoc.org/github.com/casbin/casbin?status.svg)](https://pkg.go.dev/github.com/grepplabs/casbin-kube)\n[![Release](https://img.shields.io/github/v/release/grepplabs/casbin-kube?sort=semver)](https://github.com/grepplabs/casbin-kube/releases)\n\nCasbin Kube is the [Kubernetes](https://kubernetes.io/) adapter for [Casbin](https://github.com/casbin/casbin). This library allows Casbin to load policies from Kubernetes and save policies back to it\n\nThe adapter integrates with the Kubernetes **Informer** mechanism to notify about policy changes.\n\n## Kubernetes \n\nYou need to install the `rules.casbin.grepplabs.com` custom resource and grant access to this CRD\n\n```\nkubectl apply -k config/crds\nkubectl apply -k config/rbac\n```\nor\n\n```\nhelm install casbin-kube oci://ghcr.io/grepplabs/helm/casbin-kube:0.0.1\n```\n\n## Tools\n### [casbin-kube-converter](tools/cmd/casbin-kube-converter/README.md)\n\n## Installation\n\n    go get github.com/grepplabs/casbin-kube\n\n## Usage Examples\n\n### Sample data\n\n```yaml\napiVersion: casbin.grepplabs.com/v1alpha1\nkind: Rule\nmetadata:\n  name: rule-sample\nspec:\n  ptype: \"p\"\n  v0: \"alice\"\n  v1: \"data\"\n  v2: \"read\"\n``` \n\n### Policy editor / admin \n\n```go\npackage main\n\nimport (\n    \"github.com/casbin/casbin/v3\"\n    casbinkube \"github.com/grepplabs/casbin-kube\"\n)\n\nfunc main() {\n    // Initialize a casbin kube adapter and use it in a Casbin enforcer:\n    kubeconfig := casbinkube.KubeConfig{}\n    a, _ := casbinkube.NewAdapter(\u0026casbinkube.AdapterConfig{KubeConfig: kubeconfig})\n    e, _ := casbin.NewSyncedEnforcer(\"examples/rbac_model.conf\", a)\n\n    // Load the policy from Kubernetes.\n    e.LoadPolicy()\n\n    // Check the permission.\n    e.Enforce(\"alice\", \"data1\", \"read\")\n\n    // Modify the policy.\n    // e.AddPolicy(...)\n    // e.RemovePolicy(...)\n\n    // Save the policy back to Kubernetes.\n    e.SavePolicy()\n}\n```\n\n### Policy reader / enforcer\n\nCasbin provides a [watcher](https://casbin.org/docs/watchers) mechanism to maintain consistency between multiple Casbin enforcer instances. \nWatchers can still be used with the adapter, but `Casbin Kube` natively supports the Kubernetes `Informer` mechanism to notify about policy changes, \nwhich eliminates the need for a watcher.\n\nThe Informer will automatically disable auto-save (`e.EnableAutoSave(false)`) and auto-notify watcher (`e.EnableAutoNotifyWatcher(false)`).\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"os/signal\"\n\t\"syscall\"\n\n\t\"github.com/casbin/casbin/v3\"\n\tcasbinkube \"github.com/grepplabs/casbin-kube\"\n\t\"github.com/grepplabs/loggo/zlog\"\n\tctrl \"sigs.k8s.io/controller-runtime\"\n)\n\nfunc main() {\n\tctrl.SetLogger(zlog.Logger)\n\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)\n\tdefer stop()\n\n\t// Initialize a casbin kube adapter and use it in a Casbin enforcer:\n\tkubeconfig := casbinkube.KubeConfig{}\n\ta, _ := casbinkube.NewAdapter(\u0026casbinkube.AdapterConfig{KubeConfig: kubeconfig})\n\te, _ := casbin.NewSyncedEnforcer(\"examples/rbac_model.conf\", a)\n\n\ti, _ := casbinkube.NewInformer(\u0026casbinkube.InformerConfig{KubeConfig: kubeconfig}, e)\n\tdefer i.Close()\n\ti.Start(ctx)\n\n\t// Check the permission.\n\te.Enforce(\"alice\", \"data1\", \"read\")\n\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrepplabs%2Fcasbin-kube","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrepplabs%2Fcasbin-kube","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrepplabs%2Fcasbin-kube/lists"}