{"id":13843362,"url":"https://github.com/jcasbin/shiro-casbin","last_synced_at":"2025-06-20T02:34:30.132Z","repository":{"id":40999567,"uuid":"131312677","full_name":"jcasbin/shiro-casbin","owner":"jcasbin","description":"Apache Shiro's authorization middleware based on Casbin","archived":false,"fork":false,"pushed_at":"2024-10-19T00:43:07.000Z","size":55,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T19:12:12.508Z","etag":null,"topics":["abac","access-control","authorization","casbin","plugin","rbac","shiro"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/jcasbin","language":"Java","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/jcasbin.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}},"created_at":"2018-04-27T15:15:42.000Z","updated_at":"2024-10-02T07:46:58.000Z","dependencies_parsed_at":"2022-08-24T17:51:25.876Z","dependency_job_id":null,"html_url":"https://github.com/jcasbin/shiro-casbin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jcasbin/shiro-casbin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fshiro-casbin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fshiro-casbin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fshiro-casbin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fshiro-casbin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcasbin","download_url":"https://codeload.github.com/jcasbin/shiro-casbin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fshiro-casbin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260866484,"owners_count":23074840,"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":["abac","access-control","authorization","casbin","plugin","rbac","shiro"],"created_at":"2024-08-04T17:02:00.854Z","updated_at":"2025-06-20T02:34:25.113Z","avatar_url":"https://github.com/jcasbin.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# shiro-casbin\n\n[![codebeat badge](https://codebeat.co/badges/c2cae61f-cdf9-4ca4-b22e-cffd99a6006e)](https://codebeat.co/projects/github-com-jcasbin-shiro-casbin-master)\n[![Build Status](https://github.com/jcasbin/shiro-casbin/actions/workflows/ci.yml/badge.svg)](https://github.com/jcasbin/shiro-casbin/actions/workflows/ci.yml)\n[![Coverage Status](https://codecov.io/gh/jcasbin/shiro-casbin/branch/master/graph/badge.svg)](https://codecov.io/gh/jcasbin/shiro-casbin?branch=master)\n[![Javadocs](https://www.javadoc.io/badge/org.casbin/shiro-casbin.svg)](https://www.javadoc.io/doc/org.casbin/shiro-casbin)\n[![Maven Central](https://img.shields.io/maven-central/v/org.casbin/shiro-casbin.svg)](https://mvnrepository.com/artifact/org.casbin/shiro-casbin/latest)\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord\u0026label=discord\u0026color=5865F2)](https://discord.gg/S5UjpzGZjN)\n\nApache Shiro's RBAC \u0026amp; ABAC Authorization Plug-in based on jCasbin\n\n## How it works?\n\n**1.Add configuration**\n\nYou need to specify the path of the model file in the configuration file.\n\n```yaml\nshiro-jcasbin:\n  // madel path\n  modelPath: src/test/resources/model/rbac_model.conf\n````\n\nOf course, you also need to configure the data source information in the spring configuration file. For example:\n\n```yaml\nshiro-jcasbin:\n  // madel path\n  modelPath: src/test/resources/model/rbac_model.conf\n\nspring:\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/casbin?serverTimezone=GMT%2B8\n    username: casbin_test\n    password: TEST_casbin\n```\n\n**2.Enable annotation interception**\n\nYou need to enable annotation interception in Shiro's configuration file. As for annotation startup classes, please use the ShiroAdvisor, like this:\n\n```java\n@Configuration\npublic class ShiroConfig {\n    // Other configs is omitted.\n    @Bean\n    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {\n        AuthorizationAttributeSourceAdvisor advisor = new ShiroAdvisor();\n        advisor.setSecurityManager(securityManager);\n        return advisor;\n    }\n}\n```\n\n**3.Use the EnforcerAuth annotation.**\n\nNow you can use the EnforcerAuth annotation to the controller method, like this:\n```java\n@RestController\npublic class EnforcerAuthController {\n    // Other methods is omitted.\n    @EnforcerAuth\n    @GetMapping(\"/data\")\n    public String function1() {\n        return \"success\";\n    }\n}\n```\n\nIt will verify whether the current login user has the requested address permission. If the current login user has the permission, this controller method will work properly. If not, it will throw the exception which can prompt you that the current login user does not have the permission.If no user is currently logged in, it will throw the exception which can prompt you that you should login in.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcasbin%2Fshiro-casbin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcasbin%2Fshiro-casbin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcasbin%2Fshiro-casbin/lists"}