{"id":13794014,"url":"https://github.com/gin-contrib/authz","last_synced_at":"2025-05-16T10:07:35.586Z","repository":{"id":39873877,"uuid":"92703967","full_name":"gin-contrib/authz","owner":"gin-contrib","description":"gin-authz is an authorization middleware for Gin","archived":false,"fork":false,"pushed_at":"2024-08-28T15:03:39.000Z","size":84,"stargazers_count":745,"open_issues_count":1,"forks_count":52,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-29T15:22:40.987Z","etag":null,"topics":["casbin","gin","gin-gonic"],"latest_commit_sha":null,"homepage":null,"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/gin-contrib.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":"2017-05-29T03:39:49.000Z","updated_at":"2024-10-22T14:22:18.000Z","dependencies_parsed_at":"2023-01-31T00:21:26.347Z","dependency_job_id":"60c07ba1-f25d-4aa1-8ad0-aa9f257acef1","html_url":"https://github.com/gin-contrib/authz","commit_stats":{"total_commits":96,"total_committers":6,"mean_commits":16.0,"dds":0.21875,"last_synced_commit":"74c3912c1cade89e84d0cd043599596febde6dd7"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fauthz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fauthz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fauthz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fauthz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gin-contrib","download_url":"https://codeload.github.com/gin-contrib/authz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509476,"owners_count":22082891,"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":["casbin","gin","gin-gonic"],"created_at":"2024-08-03T23:00:34.693Z","updated_at":"2025-05-16T10:07:30.579Z","avatar_url":"https://github.com/gin-contrib.png","language":"Go","readme":"# Authz\n\n[![CodeQL](https://github.com/gin-contrib/authz/actions/workflows/codeql.yml/badge.svg)](https://github.com/gin-contrib/authz/actions/workflows/codeql.yml)\n[![Run Tests](https://github.com/gin-contrib/authz/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/gin-contrib/authz/actions/workflows/go.yml)\n[![codecov](https://codecov.io/gh/gin-contrib/authz/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/authz)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/authz)](https://goreportcard.com/report/github.com/gin-contrib/authz)\n[![GoDoc](https://godoc.org/github.com/gin-contrib/authz?status.svg)](https://godoc.org/github.com/gin-contrib/authz)\n[![Join the chat at https://gitter.im/gin-gonic/gin](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gin-gonic/gin)\n\nAuthz is an authorization middleware for [Gin](https://github.com/gin-gonic/gin), it's based on [https://github.com/casbin/casbin](https://github.com/casbin/casbin).\n\n## Installation\n\n```bash\ngo get github.com/gin-contrib/authz\n```\n\n## Simple Example\n\n```Go\npackage main\n\nimport (\n  \"net/http\"\n\n  \"github.com/casbin/casbin/v2\"\n  \"github.com/gin-contrib/authz\"\n  \"github.com/gin-gonic/gin\"\n)\n\nfunc main() {\n  // load the casbin model and policy from files, database is also supported.\n  e := casbin.NewEnforcer(\"authz_model.conf\", \"authz_policy.csv\")\n\n  // define your router, and use the Casbin authz middleware.\n  // the access that is denied by authz will return HTTP 403 error.\n  router := gin.New()\n  router.Use(authz.NewAuthorizer(e))\n}\n```\n\n## Documentation\n\nThe authorization determines a request based on ``{subject, object, action}``, which means what ``subject`` can perform what ``action`` on what ``object``. In this plugin, the meanings are:\n\n1. ``subject``: the logged-on user name\n2. ``object``: the URL path for the web resource like \"dataset1/item1\"\n3. ``action``: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like \"read-file\", \"write-blog\"\n\nFor how to write authorization policy and other details, please refer to [the Casbin's documentation](https://github.com/casbin/casbin).\n\n## Getting Help\n\n- [Casbin](https://github.com/casbin/casbin)\n\n## License\n\nThis project is under MIT License. See the [LICENSE](LICENSE) file for the full license text.\n","funding_links":[],"categories":["Middlewares","Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Fauthz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgin-contrib%2Fauthz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Fauthz/lists"}