{"id":25253245,"url":"https://github.com/mmikalsen/casbun","last_synced_at":"2026-05-02T04:36:42.766Z","repository":{"id":276884832,"uuid":"924952682","full_name":"mmikalsen/casbun","owner":"mmikalsen","description":"bun adapter for casbin","archived":false,"fork":false,"pushed_at":"2025-02-11T00:30:33.000Z","size":14,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T00:47:36.539Z","etag":null,"topics":["bun","casbin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmikalsen.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}},"created_at":"2025-01-30T23:47:23.000Z","updated_at":"2025-02-11T00:05:57.000Z","dependencies_parsed_at":"2025-02-11T00:47:39.683Z","dependency_job_id":"81a272d4-c496-4fa7-a01a-12a12c430efc","html_url":"https://github.com/mmikalsen/casbun","commit_stats":null,"previous_names":["mmikalsen/casbun"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmikalsen%2Fcasbun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmikalsen%2Fcasbun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmikalsen%2Fcasbun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmikalsen%2Fcasbun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmikalsen","download_url":"https://codeload.github.com/mmikalsen/casbun/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411240,"owners_count":20934650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bun","casbin"],"created_at":"2025-02-12T04:58:47.873Z","updated_at":"2026-05-02T04:36:37.731Z","avatar_url":"https://github.com/mmikalsen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CasBun\nCasBun is a [Bun](https://bun.uptrace.dev/) ORM adapter for [Casbin](https://casbin.org/).\nWith this library, Casbin can load policy from bun supported database or save policy to it.\n\n\n##  Installation \n```\ngo get github.com/mmikalsen/casbun\n```\n\n## Simple Example\n```go\npackage main\n\nimport (\n\t\"github.com/mmikalsen/casbun\"\n\t\"github.com/casbin/casbin/v2\"\n)\n\nfunc main() {\n\tsqldb, _ := sql.Open(sqliteshim.ShimName, \"file::memory:?cache=shared\"\")\n\tdb := bun.NewDB(sqldb, sqlitedialect.New())\n\n\ta, _ := casbun.NewAdapter(ctx, db)\n\te, _ := casbin.NewEnforcer(\"model.conf\", a)\n\n\t// check the permission.\n\t_, _ = e.Enforce(\"alice\", \"data1\", \"read\")\n\n\t// save the policy back to DB.\n\t_ = e.SavePolicy()\n}\n```\n\n## Context Adapter \n`casbun` supports adapter with context, the following is a timeout control implemented using context\n\n```go \na, _ = casbun.NewAdapter(ctx, db)\n// Limited time 300s\nctx, cancel := context.WithTimeout(context.Background(), 300*time.Microsecond)\ndefer cancel()\nerr := a.AddPolicyCtx(ctx, \"p\", \"p\", []string{\"alice\", \"data1\", \"read\"})\nif err != nil {\n    panic(err)\n}\n```\n\n## Credits  \nThis adapter is a rewrite of the original\n[junishimura/casbin-bun-adapter](https://github.com/JunNishimura/casbin-bun-adapter)\n, with a focus on reducing unnecessary dependencies, preserving core\nfunctionality, and improving the integration with Bun.\n\n\n## License\ncasbin-bun-adapter is released under [MIT License](https://github.com/mmikalsen/casbun/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmikalsen%2Fcasbun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmikalsen%2Fcasbun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmikalsen%2Fcasbun/lists"}