casbin/casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Golang

GoMakefilegoidentityoauthsamlauthenticationiamaclauthauthorizationcaspermissionrbacssooidcaccess-controlabacauthzauthncasbincasdoor

Stars and forks stats for /casbin/casbin

1 523 forks on 2023-03-081 523 forks on 2023-03-091 523 forks on 2023-03-101 523 forks on 2023-03-111 523 forks on 2023-03-121 523 forks on 2023-03-131 523 forks on 2023-03-141 523 forks on 2023-03-151 524 forks on 2023-03-161 524 forks on 2023-03-171 526 forks on 2023-03-181 526 forks on 2023-03-191 526 forks on 2023-03-201 525 forks on 2023-03-211 526 forks on 2023-03-221 525 forks on 2023-03-231 527 forks on 2023-03-241 530 forks on 2023-03-251 530 forks on 2023-03-261 532 forks on 2023-03-271 532 forks on 2023-03-281 535 forks on 2023-03-291 535 forks on 2023-03-301 535 forks on 2023-03-311 535 forks on 2023-04-011 535 forks on 2023-04-021 537 forks on 2023-04-031 536 forks on 2023-04-041 537 forks on 2023-04-051 536 forks on 2023-04-061 537 forks on 2023-04-071 539 forks on 2023-04-081 539 forks on 2023-04-091 539 forks on 2023-04-101 541 forks on 2023-04-111 542 forks on 2023-04-121 542 forks on 2023-04-131 542 forks on 2023-04-141 542 forks on 2023-04-151 543 forks on 2023-04-161 543 forks on 2023-04-171 544 forks on 2023-04-181 544 forks on 2023-04-191 546 forks on 2023-04-201 547 forks on 2023-04-211 547 forks on 2023-04-221 547 forks on 2023-04-231 548 forks on 2023-04-241 550 forks on 2023-04-251 550 forks on 2023-04-261 550 forks on 2023-04-271 550 forks on 2023-04-281 550 forks on 2023-04-291 551 forks on 2023-04-301 551 forks on 2023-05-011 551 forks on 2023-05-021 551 forks on 2023-05-031 551 forks on 2023-05-041 553 forks on 2023-05-051 555 forks on 2023-05-061 557 forks on 2023-05-071 560 forks on 2023-05-081 560 forks on 2023-05-091 560 forks on 2023-05-101 559 forks on 2023-05-111 560 forks on 2023-05-121 560 forks on 2023-05-131 560 forks on 2023-05-141 561 forks on 2023-05-151 561 forks on 2023-05-161 561 forks on 2023-05-171 561 forks on 2023-05-181 562 forks on 2023-05-191 562 forks on 2023-05-201 563 forks on 2023-05-211 564 forks on 2023-05-221 568 forks on 2023-05-231 571 forks on 2023-05-241 576 forks on 2023-05-251 576 forks on 2023-05-261 577 forks on 2023-05-271 577 forks on 2023-05-281 576 forks on 2023-05-291 576 forks on 2023-05-301 579 forks on 2023-05-311 580 forks on 2023-06-011 580 forks on 2023-06-021 580 forks on 2023-06-031 580 forks on 2023-06-041 580 forks on 2023-06-05

1.6kforks in total +67last 90 days

13 930 stars on 2023-03-0813 948 stars on 2023-03-0913 958 stars on 2023-03-1013 958 stars on 2023-03-1113 968 stars on 2023-03-1213 973 stars on 2023-03-1313 982 stars on 2023-03-1413 982 stars on 2023-03-1513 989 stars on 2023-03-1613 997 stars on 2023-03-1713 998 stars on 2023-03-1814 000 stars on 2023-03-1914 000 stars on 2023-03-2014 009 stars on 2023-03-2114 037 stars on 2023-03-2214 049 stars on 2023-03-2314 064 stars on 2023-03-2414 075 stars on 2023-03-2514 081 stars on 2023-03-2614 095 stars on 2023-03-2714 095 stars on 2023-03-2814 113 stars on 2023-03-2914 113 stars on 2023-03-3014 130 stars on 2023-03-3114 151 stars on 2023-04-0114 151 stars on 2023-04-0214 167 stars on 2023-04-0314 177 stars on 2023-04-0414 181 stars on 2023-04-0514 184 stars on 2023-04-0614 190 stars on 2023-04-0714 197 stars on 2023-04-0814 201 stars on 2023-04-0914 208 stars on 2023-04-1014 220 stars on 2023-04-1114 234 stars on 2023-04-1214 247 stars on 2023-04-1314 252 stars on 2023-04-1414 252 stars on 2023-04-1514 265 stars on 2023-04-1614 265 stars on 2023-04-1714 278 stars on 2023-04-1814 278 stars on 2023-04-1914 296 stars on 2023-04-2014 304 stars on 2023-04-2114 307 stars on 2023-04-2214 315 stars on 2023-04-2314 333 stars on 2023-04-2414 345 stars on 2023-04-2514 345 stars on 2023-04-2614 357 stars on 2023-04-2714 363 stars on 2023-04-2814 369 stars on 2023-04-2914 373 stars on 2023-04-3014 378 stars on 2023-05-0114 380 stars on 2023-05-0214 380 stars on 2023-05-0314 380 stars on 2023-05-0414 399 stars on 2023-05-0514 418 stars on 2023-05-0614 428 stars on 2023-05-0714 436 stars on 2023-05-0814 436 stars on 2023-05-0914 447 stars on 2023-05-1014 459 stars on 2023-05-1114 464 stars on 2023-05-1214 464 stars on 2023-05-1314 470 stars on 2023-05-1414 474 stars on 2023-05-1514 484 stars on 2023-05-1614 490 stars on 2023-05-1714 502 stars on 2023-05-1814 512 stars on 2023-05-1914 517 stars on 2023-05-2014 528 stars on 2023-05-2114 571 stars on 2023-05-2214 605 stars on 2023-05-2314 696 stars on 2023-05-2414 790 stars on 2023-05-2514 812 stars on 2023-05-2614 821 stars on 2023-05-2714 833 stars on 2023-05-2814 858 stars on 2023-05-2914 869 stars on 2023-05-3014 922 stars on 2023-05-3114 943 stars on 2023-06-0114 954 stars on 2023-06-0214 960 stars on 2023-06-0314 962 stars on 2023-06-0414 978 stars on 2023-06-05

15kstars in total +1.1klast 90 days

This is stars and forks stats for /casbin/casbin repository. As of 05 Jun, 2023 this repository has 14978 stars and 1580 forks.

Casbin 💖 Looking for an open-source identity and access management solution like Okta, Auth0, Keycloak ? Learn more about: Casdoor News: still worry about how to write the correct Casbin policy? Casbin online editor is coming to help! Try it at: https://casbin.org/editor/ Casbin is a powerful and efficient open-source access control library for Golang projects. It provides support for enforcing authorization based on various access control models. All the languages supported by Casbin: Casbin jCasbin node-Casbin PHP-Casbin production-ready production-ready production-ready production-ready PyCasbin Casbin.NET Casbin-CPP Casbin-RS production-ready production-ready beta-test production-ready Table of contents Supported models How it works? Features Installation Documentation Online editor Tutorials Get started Policy management Policy persistence Policy consistence between multiple nodes Role manager Benchmarks Examples Middlewares Our adopters Supported models ACL (Access Control List) ACL with superuser ACL without users: especially useful for systems that don't have authentication or user log-ins. ACL without resources: some scenarios may target for a type of resources instead of an individual resource by using permissions like write-article, read-log. It doesn't control the access to a specific article or log. RBAC (Role-Based Access Control) RBAC with resource roles: both users and resources can have roles (or groups) at the same time. RBAC with domains/tenants: users can have different role sets for different domains/tenants. ABAC (Attribute-Based Access Control): syntax sugar like resource.Owner can be used to get the attribute for a resource. RESTful: supports paths like /res/*, /res/:id and HTTP methods like GET, POST, PUT, DELETE. Deny-override: both allow and deny authorizations are supported, deny overrides the allow. Priority: the policy rules can be prioritized like firewall rules. How it works? In Casbin, an access control model is abstracted into a CONF file based on the PERM metamodel (Policy, Effect, Request, Matchers). So switching or upgrading the authorization mechanism for a project is just as simple as modifying a configuration. You can customize your own access control model by combining the available models. For example, you can get RBAC roles and ABAC attributes together inside one model and share one set of policy rules. The most basic and simplest model in Casbin is ACL. ACL's model CONF is: # Request definition [request_definition] r = sub, obj, act # Policy definition [policy_definition] p = sub, obj, act # Policy effect [policy_effect] e = some(where (p.eft == allow)) # Matchers [matchers] m = r.sub == p.sub && r.obj == p.obj && r.act == p.act An example policy for ACL model is like: p, alice, data1, read p, bob, data2, write It means: alice can read data1 bob can write data2 We also support multi-line mode by appending '\' in the end: # Matchers [matchers] m = r.sub == p.sub && r.obj == p.obj \ && r.act == p.act Further more, if you are using ABAC, you can try operator in like following in Casbin golang edition (jCasbin and Node-Casbin are not supported yet): # Matchers [matchers] m = r.obj == p.obj && r.act == p.act || r.obj in ('data2', 'data3') But you SHOULD make sure that the length of the array is MORE than 1, otherwise there will cause it to panic. For more operators, you may take a look at govaluate Features What Casbin does: enforce the policy in the classic {subject, object, action} form or a customized form as you defined, both allow and deny authorizations are supported. handle the storage of the access control model and its policy. manage the role-user mappings and role-role mappings (aka role hierarchy in RBAC). support built-in superuser like root or administrator. A superuser can do anything without explicit permissions. multiple built-in operators to support the rule matching. For example, keyMatch can map a resource key /foo/bar to the pattern /foo*. What Casbin does NOT do: authentication (aka verify username and password when a user logs in) manage the list of users or roles. I believe it's more convenient for the project itself to manage these entities. Users usually have their passwords, and Casbin is not designed as a password container. However, Casbin stores the user-role mapping for the RBAC scenario. Installation go get github.com/casbin/casbin/v2 Documentation https://casbin.org/docs/overview Online editor You can also use the online editor (https://casbin.org/editor/) to write your Casbin model and policy in your web browser. It provides functionality such as syntax highlighting and code completion, just like an IDE for a programming language. Tutorials https://casbin.org/docs/tutorials Get started New a Casbin enforcer with a model file and a policy file: e, _ := casbin.NewEnforcer("path/to/model.conf", "path/to/policy.csv") Note: you can also initialize an enforcer with policy in DB instead of file, see Policy-persistence section for details. Add an enforcement hook into your code right before the access happens: sub := "alice" // the user that wants to access a resource. obj := "data1" // the resource that is going to be accessed. act := "read" // the operation that the user performs on the resource. if res, _ := e.Enforce(sub, obj, act); res { // permit alice to read data1 } else { // deny the request, show an error } Besides the static policy file, Casbin also provides API for permission management at run-time. For example, You can get all the roles assigned to a user as below: roles, _ := e.GetImplicitRolesForUser(sub) See Policy management APIs for more usage. Policy management Casbin provides two sets of APIs to manage permissions: Management API: the primitive API that provides full support for Casbin policy management. RBAC API: a more friendly API for RBAC. This API is a subset of Management API. The RBAC users could use this API to simplify the code. We also provide a web-based UI for model management and policy management: Policy persistence https://casbin.org/docs/adapters Policy consistence between multiple nodes https://casbin.org/docs/watchers Role manager https://casbin.org/docs/role-managers Benchmarks https://casbin.org/docs/benchmark Examples Model Model file Policy file ACL basic_model.conf basic_policy.csv ACL with superuser basic_model_with_root.conf basic_policy.csv ACL without users basic_model_without_users.conf basic_policy_without_users.csv ACL without resources basic_model_without_resources.conf basic_policy_without_resources.csv RBAC rbac_model.conf rbac_policy.csv RBAC with resource roles rbac_model_with_resource_roles.conf rbac_policy_with_resource_roles.csv RBAC with domains/tenants rbac_model_with_domains.conf rbac_policy_with_domains.csv ABAC abac_model.conf N/A RESTful keymatch_model.conf keymatch_policy.csv Deny-override rbac_model_with_deny.conf rbac_policy_with_deny.csv Priority priority_model.conf priority_policy.csv Middlewares Authz middlewares for web frameworks: https://casbin.org/docs/middlewares Our adopters https://casbin.org/docs/adopters How to Contribute Please read the contributing guide. Contributors This project exists thanks to all the people who contribute. Backers Thank you to all our backers! 🙏 [Become a backer] Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor] Star History License This project is licensed under the Apache 2.0 license. Contact If you have any issues or feature requests, please contact us. PR is welcomed. https://github.com/casbin/casbin/issues [email protected] Tencent QQ group: 546057381
Read on GithubGithub Stats Page
repotechsstarsweeklyforksweekly
accurics/terrascanGoOpen Policy AgentShell4.1k04670
pion/webrtcGoOther11.3k+481.4k+3
hashicorp/consul-k8sGoShellOther60902810
lacework/terraform-aws-cloudtrailHCLShellMakefile50200
umotif-public/terraform-aws-ecs-fargate-scheduled-taskHCLMakefile10070
knyar/nginx-lua-prometheusLuaGoShell1.3k+12130
Clever/go-process-metricsMakefileGo0010
aws-samples/ecs-refarch-cloudformationMakefileGoDockerfile1.6k+21.3k+2
OpenModelica/OpenModelicaModelicaCC++606+1258+1
ministryofjustice/hmpps-helm-chartsMustacheShellSmarty1030