{"id":13671049,"url":"https://github.com/casbin/hraft-dispatcher","last_synced_at":"2025-06-29T17:03:27.547Z","repository":{"id":41857177,"uuid":"340909885","full_name":"casbin/hraft-dispatcher","owner":"casbin","description":"A dispatcher based on Hashicorp's Raft for Casbin.","archived":false,"fork":false,"pushed_at":"2023-09-17T10:02:09.000Z","size":159,"stargazers_count":18,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-11T12:33:28.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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":"2021-02-21T13:37:23.000Z","updated_at":"2024-04-06T15:56:24.000Z","dependencies_parsed_at":"2023-09-26T09:08:29.830Z","dependency_job_id":null,"html_url":"https://github.com/casbin/hraft-dispatcher","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":"0.032786885245901676","last_synced_commit":"f8b8f6b58c7335d2b69f010d9e4b4b5c3580adf0"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/casbin/hraft-dispatcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fhraft-dispatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fhraft-dispatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fhraft-dispatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fhraft-dispatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/hraft-dispatcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fhraft-dispatcher/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260918267,"owners_count":23082526,"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":[],"created_at":"2024-08-02T09:00:56.959Z","updated_at":"2025-06-29T17:03:27.481Z","avatar_url":"https://github.com/casbin.png","language":"Go","funding_links":["https://github.com/sponsors/casbin"],"categories":["Go"],"sub_categories":[],"readme":"# hraft-dispatcher \n\n[![Go Report Card](https://goreportcard.com/badge/github.com/casbin/hraft-dispatcher)](https://goreportcard.com/report/github.com/casbin/hraft-dispatcher)\n[![Build Status](https://github.com/casbin/hraft-dispatcher/actions/workflows/main.yml/badge.svg)](https://github.com/casbin/hraft-dispatcher/actions?workflow=main)\n[![Godoc](https://godoc.org/github.com/casbin/hraft-dispatcher?status.svg)](https://pkg.go.dev/github.com/casbin/hraft-dispatcher)\n[![Release](https://img.shields.io/github/v/release/casbin/hraft-dispatcher)](https://github.com/casbin/hraft-dispatcher/releases)\n[![Sourcegraph](https://sourcegraph.com/github.com/casbin/hraft-dispatcher/-/badge.svg)](https://sourcegraph.com/github.com/casbin/hraft-dispatcher?badge)\n[![License](https://img.shields.io/github/license/casbin/hraft-dispatcher?color=blue)](https://github.com/casbin/hraft-dispatcher/blob/main/LICENSE)\n\nA dispatcher based on Hashicorp's Raft for Casbin.\n\n## Project Status\n\nhraft-dispatcher is beta version.\n\n## Getting started\n\n### Installation\n\nGo version 1.14+ and Casbin vervsion 2.24+ is required.\n\n```shell\ngo get github.com/casbin/hraft-dispatcher\n```\n\n### Prerequisite\n\nYou have to provide a completely new Casbin environment without Adapter, all the policies are handled by hraft-dispatcher. \nWhen the leader node starts for the first time, you can add the default policy to hraft-dispatcher.\n\n### Example\n\nAn example is provided [here](./example).\n\n### Security\n\nWe support enable TLS on HTTP service and Raft service. \nIf you provide the TLS config is not nil, we will configure this to HTTP service and Raft service, and the HTTP upgrade HTTPS.\n\nwhen TLS is enabled, a peer certificate must be provided. It is recommended to use [cfssl](https://github.com/cloudflare/cfssl) to generate this certificate, our generate script is [here](./testdata/ca/generate.sh).\n\nHere is out configuration, you can find it in [example](./example/main.go):\n```go\ntls.Config{\n    RootCAs:      rootCAPool,\n    ClientCAs:    rootCAPool,\n    ClientAuth:   tls.RequireAndVerifyClientCert,\n    Certificates: []tls.Certificate{cert},\n}\n```\n\n## Architecture\n\nhraft-dispatcher is a [dispatcher](https://casbin.org/docs/dispatchers/) plug-in based on [hashicorp/raft](https://github.com/hashicorp/raft) implementation.\n\nhraft-dispatcher includes an HTTP service, and a Raft service:\n\n- HTTP service is used to forward data from follower node to follower node\n- Raft service is used to maintain the policy consistency of each node\n\nIf you set up a dispatcher in Casbin, it forwards the following request to dispatcher:\n\n- AddPolicy\n- RemovePolicy\n- AddPolicies\n- RemovePolicies\n- RemoveFilteredPolicy\n- UpdatePolicy\n- UpdatePolicies\n- ClearPolicy\n\nIn dispatcher, we are use Raft consensus protocol to maintain the policy, and use the [bbolt](https://github.com/etcd-io/bbolt) to storage the policy of each node.\n\nhraft-dispatcher overall architecture looks like this:\n\n![overall architecture](./docs/images/dispatcher-architecture.svg)\n\n## Limitations\n\n- Adapter: You cannot use Adapter in Casbin, hraft-dispatcher has its own Adapter, which uses the [bbolt](https://github.com/etcd-io/bbolt) to storage the policy.\n- You cannot call the following methods, which will affect data consistency:\n  - LoadPolicy - All policies are maintained by hraft-dispatcher\n  - SavePolicy - All policies are maintained by hraft-dispatcher\n\n\n## Project reference\n\nMuch of the inspiration comes from the following projects:\n\n- [rqlite](https://github.com/rqlite/rqlite)\n- [vault](https://github.com/hashicorp/vault)\n\nThanks for everyone's contribution.\n\n## Contribution\n\nThank you for your interest in contributing!\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%2Fhraft-dispatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fhraft-dispatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fhraft-dispatcher/lists"}