Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buession/buession-shirojs
A security framework for JavaScript or TypeScript.
https://github.com/buession/buession-shirojs
authentication authorization javascript permission privilege security shiro typescript vue
Last synced: 10 days ago
JSON representation
A security framework for JavaScript or TypeScript.
- Host: GitHub
- URL: https://github.com/buession/buession-shirojs
- Owner: buession
- License: mit
- Created: 2021-12-03T01:41:01.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-05T09:24:12.000Z (12 months ago)
- Last Synced: 2024-12-05T17:43:38.567Z (19 days ago)
- Topics: authentication, authorization, javascript, permission, privilege, security, shiro, typescript, vue
- Language: TypeScript
- Homepage: https://shirojs.buession.com/
- Size: 370 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Buession Shiro
## 为什么选择 Buession Shiro
在前后端分离项目中(如:Vue、Angular、React等),前端常常涉及到根据权限显示数据、操作等等重复的实现所困惑。每当开启一个新项目时,我们都得手动重复去编写这些代码,而且还难免代码逻辑不一致,质量参差不齐。
Buession ShiroJs 旨在提供便捷的、统一的、可靠的权限前端权限验证功能。在业务开发中省去的那些“脏活累活”,专注于业务核心的开发。
Buession ShiroJs 的核心思想参考 [Apache Shiro](http://shiro.apache.org/) 。
## 安装
您可以通过 [NPM](https://www.npmjs.com/)、[YARN](https://yarnpkg.com/) 或者通过 `` 的方式引入 [unpkg.com](https://unpkg.com/) 上的包。
### NPM
```sh
npm install @buession/shiro
# or
yarn add @buession/shiro
```### CDN
> 对于生产环境,我们推荐链接到一个明确的版本号和构建文件,以避免新版本造成的不可预期的破坏。
```html
最新版:<script src="https://unpkg.com/@buession/shiro/dist/shiro.min.js" type="text/javascript">
具体版本:
```## 示例
```vue
Admin
Edit
Action
import { defineComponent } from 'vue';
export default defineComponent({
setup() {
}
});```
```javascript
function Principal(){
this.id = '1';
}Principal.prototype.getId = function(){
return this.id;
}Principal.prototype.getRoles = function(){
return ["admin", "admin1"];
}Principal.prototype.getPermissions = function(){
return ["user:add", "user:edit"];
}var shiro = new Shiro(new Principal());
if (shiro.hasRole("admin")) {
}```
## License
[MIT License](https://github.com/buession/buession-shirojs/blob/master/LICENSE) © 2020-2023