{"id":27120745,"url":"https://github.com/awatercolorpen/caskin","last_synced_at":"2026-03-06T16:03:24.723Z","repository":{"id":42021003,"uuid":"340577251","full_name":"AWaterColorPen/caskin","owner":"AWaterColorPen","description":"A multi-domain RBAC authorization library in Golang. Focus on management of authorization business.","archived":false,"fork":false,"pushed_at":"2024-03-14T21:54:36.000Z","size":620,"stargazers_count":16,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T10:07:27.957Z","etag":null,"topics":["authorization","casbin","domain","rbac","rbac-management","tenant","tenant-management"],"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/AWaterColorPen.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}},"created_at":"2021-02-20T06:12:22.000Z","updated_at":"2025-03-30T01:34:35.000Z","dependencies_parsed_at":"2023-10-20T18:15:43.190Z","dependency_job_id":null,"html_url":"https://github.com/AWaterColorPen/caskin","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/AWaterColorPen/caskin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWaterColorPen%2Fcaskin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWaterColorPen%2Fcaskin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWaterColorPen%2Fcaskin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWaterColorPen%2Fcaskin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AWaterColorPen","download_url":"https://codeload.github.com/AWaterColorPen/caskin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWaterColorPen%2Fcaskin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30184885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T14:42:24.748Z","status":"ssl_error","status_checked_at":"2026-03-06T14:42:14.925Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["authorization","casbin","domain","rbac","rbac-management","tenant","tenant-management"],"created_at":"2025-04-07T10:07:33.985Z","updated_at":"2026-03-06T16:03:24.707Z","avatar_url":"https://github.com/AWaterColorPen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Caskin\n\n[![Go](https://github.com/AWaterColorPen/caskin/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/AWaterColorPen/caskin/actions/workflows/go.yml)\n\nCaskin is a multi-domain rbac library for Golang projects. It develops base on [caskin](https://github.com/casbin/casbin) \n\n## Introduction\n\n### Example\n\n## Documentation\n\n1. [Configuration](./docs/configuration.md) to configure caskin instance and dictionary.\n2. [Design](./docs/design.md) for the details of design.\n3. [API](./docs/api.md) for the details of caskin service method.\n\n## Getting Started\n\n### Define the dictionary configuration file\n\nCreate a new file for example named `caskin.toml` to define\n[feature](./docs/configuration.md#feature),\n[backend](./docs/configuration.md#backend),\n[frontend](./docs/configuration.md#frontend),\n[package](./docs/configuration.md#package),\n[creator_object](./docs/configuration.md#creator-object),\n[creator_role](./docs/configuration.md#creator-role),\n[creator_policy](./docs/configuration.md#creator-policy).\n\n```toml\nfeature = [\n    {name = \"feature\"},\n]\n\nbackend = [\n    {path = \"api/feature\", method = \"GET\"},\n    {path = \"api/feature\", method = \"POST\"},\n]\n\nfrontend = [\n    {name = \"feature\", type = \"menu\"},\n]\n\npackage = [\n    {key = \"feature\", backend = [[\"api/feature\", \"GET\"], [\"api/feature\", \"POST\"]], frontend = [[\"feature\", \"menu\"]]},\n]\n\ncreator_object = [\n    {name = \"role_root\", type = \"role\"},\n]\n\ncreator_role = [\n    {name = \"admin\"},\n    {name = \"member\"},\n]\n\ncreator_policy = [\n    {role = \"admin\", object = \"role_root\", action = [\"read\", \"write\", \"manage\"]},\n    {role = \"admin\", object = \"github.com/awatercolorpen/caskin::feature\", action = [\"read\"]},\n    {role = \"member\", object = \"role_root\", action = [\"read\"]},\n]\n```\n\n### To make use of caskin in golang\n\nRegister [user-role-object-domain]() instance. \n\nIt should implement the interface of `caskin.User`, `caskin.Role`, `caskin.Object`, `caskin.Domain` generally.\nOr use the example implementation in `github.com/awatercolorpen/caskin/example` for the prototype.\n\n```golang\nimport \"github.com/awatercolorpen/caskin\"\nimport \"github.com/awatercolorpen/caskin/example\"\n\n// register instance type\ncaskin.Register[*example.User, *example.Role, *example.Object, *example.Domain]()\n```\n\nCreate a new [caskin service instance](./docs/configuration.md#service-configuration).\n\n```golang\nimport \"github.com/awatercolorpen/caskin\"\n\n// set db option\ndbOption := \u0026caskin.DBOption{\n\tDSN:  \"./sqlite.db\", \n\tType: \"sqlite\",\n}\n\n// set dictionary option\ndictionaryOption := \u0026caskin.DictionaryOption{\n\tDsn: \"caskin.toml\",\n}\n\n// build service option\noption := \u0026caskin.Options{\n\tDictionary: dictionaryOption, \n\tDB:         dbOption,\n}\n\n// create a new service instance\nservice, err := caskin.New(option)\n```\n\nInitialize first [domain](), and add first superadmin.\n\n```golang\ndomain := \u0026example.Domain{Name: \"school-1\"}\nsuperadmin := \u0026example.User{Email: \"superadmin@qq.com\"}\n\n// create domain\nerr := service.CreateDomain(domain)\n\n// reset domain by the creator setting from caskin.toml\nerr := service.ResetDomain(domain)\n\n// reset domain by the feature setting from caskin.toml\nerr := service.ResetFeature(domain)\n\n// add a user to caskin\nerr := service.CreateUser(superadmin)\n\n// set a user as superadmin\nerr := service.AddSuperadmin(p.Superadmin)\n```\n\n### To manage the authorization business\n\nUse the `caskin.Service`'s [API](./docs/api.md) to control on authorization management.\n\n```golang\n// authorization business: delete one role\nerr := service.DeleteRole(operatorUser, workingOnDomain, toDeleteRole))\n```\n\nUse the `caskin.CurrentService` interface.\n\n```golang\ncurrentService := service.SetCurrent(operatorUser, workingOnDomain)\n```\n\n## License\n\nSee the [License File](./LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawatercolorpen%2Fcaskin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawatercolorpen%2Fcaskin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawatercolorpen%2Fcaskin/lists"}