{"id":19298242,"url":"https://github.com/casbin/beego-orm-adapter","last_synced_at":"2025-04-22T09:32:20.912Z","repository":{"id":26171909,"uuid":"106807236","full_name":"casbin/beego-orm-adapter","owner":"casbin","description":"Beego ORM adapter for Casbin","archived":false,"fork":false,"pushed_at":"2023-08-10T13:30:39.000Z","size":45,"stargazers_count":21,"open_issues_count":1,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T22:37:41.857Z","etag":null,"topics":["access-control","adapter","authorization","beego","casbin","orm","storage-driver"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/casbin","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/casbin.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},"funding":{"github":"casbin"}},"created_at":"2017-10-13T09:50:38.000Z","updated_at":"2023-10-03T18:19:51.000Z","dependencies_parsed_at":"2023-09-26T09:09:01.137Z","dependency_job_id":null,"html_url":"https://github.com/casbin/beego-orm-adapter","commit_stats":{"total_commits":28,"total_committers":7,"mean_commits":4.0,"dds":0.4642857142857143,"last_synced_commit":"164ff79e9c7ab1e9f0982a16e0d5f4de51e440b7"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fbeego-orm-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fbeego-orm-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fbeego-orm-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fbeego-orm-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/beego-orm-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223175588,"owners_count":17100453,"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":["access-control","adapter","authorization","beego","casbin","orm","storage-driver"],"created_at":"2024-11-09T23:07:22.556Z","updated_at":"2024-11-09T23:07:23.186Z","avatar_url":"https://github.com/casbin.png","language":"Go","funding_links":["https://github.com/sponsors/casbin"],"categories":[],"sub_categories":[],"readme":"Beego ORM Adapter [![Go](https://github.com/casbin/beego-orm-adapter/actions/workflows/ci.yml/badge.svg)](https://github.com/casbin/beego-orm-adapter/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/casbin/beego-orm-adapter/badge.svg?branch=master)](https://coveralls.io/github/casbin/beego-orm-adapter?branch=master) [![Godoc](https://godoc.org/github.com/casbin/beego-orm-adapter?status.svg)](https://godoc.org/github.com/casbin/beego-orm-adapter)\n====\n\n#### Note: the last version that supports Beego v1 is: https://github.com/casbin/beego-orm-adapter/releases/tag/v2.0.2 . Beego v2 is supported starting from v3.0.0\n\nBeego ORM Adapter is the [Beego ORM](https://beego.me/docs/mvc/model/overview.md) adapter for [Casbin](https://github.com/casbin/casbin). With this library, Casbin can load policy from Beego ORM supported database or save policy to it.\n\nBased on [Beego ORM Support](https://beego.me/docs/mvc/model/overview.md), The current supported databases are:\n\n- MySQL: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql)\n- PostgreSQL: [github.com/lib/pq](https://github.com/lib/pq)\n- Sqlite3: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)\n\n## Installation\n```bash\ngo get github.com/casbin/beego-orm-adapter/v2\n```\n\n## Simple Example\n\n```go\npackage main\n\nimport (\n    \"log\"\n\n    beegoormadapter \"github.com/casbin/beego-orm-adapter/v3\"\n    \"github.com/casbin/casbin/v2\"\n    _ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n    // Initialize a Beego ORM adapter and use it in a Casbin enforcer:\n    a, err := beegoormadapter.NewAdapter(\"casbin\", \"mysql\", \"mysql_username:mysql_password@tcp(127.0.0.1:3306)/dbname\") // Your driver and data source. \n    if err != nil {\n        log.Fatalln(err)\n    }\n\n    e, err := casbin.NewEnforcer(\"examples/rbac_model.conf\", a)\n    if err != nil {\n        log.Fatalln(err)\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 DB.\n    e.SavePolicy()\n}\n```\n\n## Custom Table Name\n\n`Beego ORM` using `TableNameI` interface to customize the table name\n\nreference: [custom-table-name](https://github.com/beego/beedoc/blob/master/en-US/mvc/model/models.md#custom-table-name)\n\nYou can customize the name of the table by `NewAdapterWithTableName`, and query the custom table name through `GetFullTableName`\n\n```golang\nfunc testCustomTableName(t *testing.T, a *Adapter, expectTableName string) {\n    actualTableName := a.GetFullTableName()\n    if actualTableName != expectTableName {\n        t.Error(\"actual table name: \", a.GetFullTableName(), \", supposed to be \", expectTableName)\n    }\n}\n\nfunc TestAdapterCustomTableName(t *testing.T) {\n    a, err := NewAdapterWithTableName(\"customtablename\", \"mysql\", \"root:@tcp(127.0.0.1:3306)/casbin_test\", \"my_casbin\", \"prefix_\")\n    if err != nil {\n        t.Fatal(err)\n    }\n    testCustomTableName(t, a, \"prefix_my_casbin\")\n    testSaveLoad(t, a)\n    testAutoSave(t, a)\n}\n```\n\n**Note:** Currently, only one custom table name is supported, \nand no other table name should be used after the first use of `NewAdapterWithTableName`\n\n\n\n## Getting Help\n\n- [Casbin](https://github.com/casbin/casbin)\n\n## License\n\nThis project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fbeego-orm-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fbeego-orm-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fbeego-orm-adapter/lists"}