# sureness **Repository Path**: jimlijm/sureness ## Basic Information - **Project Name**: sureness - **Description**: A simple and efficient open-source jvm security framework that focus on the protection of restful api. - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://su.usthe.com - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 259 - **Created**: 2021-01-25 - **Last Updated**: 2021-01-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
# sureness - 面向restful api的认证鉴权框架 > A simple and efficient open-source jvm security framework that focus on the protection of restful api. [](https://www.apache.org/licenses/LICENSE-2.0.html)  [](https://gitter.im/usthe/sureness)  **若主页[usthe.com/sureness](https://usthe.com/sureness) 访问不了,请使用备用网站: [su.usthe.com](https://su.usthe.com/)** [英文文档 -> English Documentation](README.md) 相关文章: [restful api 权限设计 - 初探一](https://segmentfault.com/a/1190000038360856) [restful api 权限设计 - 快速搭建权限项目](https://segmentfault.com/a/1190000039075245) ## Background 现在很多网站都进行了前后端分离,后端提供rest api,前端调用接口获取数据渲染。这种架构下如何保护好后端所提供的rest api使得更加重视。 认证-请求携带的认证信息是否校验通过,鉴权-认证通过的用户拥有指定api的权限才能访问此api。然而不仅于此,什么样的认证策略, jwt, basic,digest,oauth还是多支持, 权限配置是写死代码还是动态配置赋权,云原生越来越火用的框架是quarkus而不是spring生态,http实现不是servlet而是jax-rs规范咋办。 我们希望能解决这些,提供一个面向**restful api**,**无框架依赖**,可以**动态修改权限**,**多认证策略**,**更快速度**,**易用易扩展**的认证鉴权框架 ## Introduction > `sureness` 是我们在使用 `java` 权限框架 `shiro` 之后,吸取其良好设计加上一些想法实现的全新认证鉴权项目 > 面对 `restful api` 的认证鉴权,基于 `rbac` (用户-角色-资源)主要关注于对 `restful api` 的安全保护 > 无特定框架依赖(本质就是过滤器处拦截判断,已有`springboot,quarkus,javalin,ktor`等demo) > 支持动态修改权限配置(动态修改哪些`api`需要被认证,可以被谁访问) > 支持主流`http`容器 `servlet` 和 `jax-rs` > 支持多种认证策略, `jwt, basic auth, digest auth` ... 可扩展自定义支持的认证方式 > [基于改进的字典匹配树拥有的高性能](#高性能匹配 ) > 良好的扩展接口, demo和文档 >`sureness`的低配置,易扩展,不耦合其他框架,能使开发者对自己的项目多场景快速安全的进行保护 ##### Compare | ~ | sureness | shiro | spring security | | --- | --- | --- | --- | | **多框架支持** | 支持 | 需改动支持 | 不支持 | | **restful api** | 支持 | 需改动支持 | 支持 | | **过滤链匹配** | 优化的字典匹配树 | ant匹配 | ant匹配 | | **注解支持** | 支持 | 支持 | 支持 | | **servlet** | 支持 | 支持 | 支持| | **jax-rs** | 支持 | 不支持 | 不支持| | **权限动态修改** | 支持 | 需改动支持 | 需改动支持| ##### Framework Sample Support - [x] spring [sample-bootstrap](sample-bootstrap) - [x] springboot [sample-tom](sample-tom) - [x] quarkus [sample-quarkus](samples/quarkus-sureness) - [x] javalin [sample-javalin](samples/javalin-sureness) - [x] ktor [sample-ktor](samples/ktor-sureness) - [x] spring webflux [sample-spring-webflux](samples/spring-webflux-sureness) - [x] more samples todo ## 快速开始 #### 使用前一些约定 - `sureness`尽量简洁,基于`rbac`,只有(角色-资源)的映射,没有(权限)动作映射,即 用户-角色-资源 - 我们将`restful api`请求视作一个资源,资源格式为: `requestUri===httpMethod` 即请求的路径加上其请求方式(`post,get,put,delete...`)作为一个整体被视作一个资源 `eg: /api/v2/book===get` `get`方式请求`/api/v2/book`接口数据 - 角色资源映射: 用户所属角色--角色拥有资源--用户拥有资源(用户就能访问此`api`) 资源路径匹配详见 [URI路径匹配](docs/cn/path-match.md) #### 项目中加入sureness 项目使用`maven`或`gradle`构建,加入坐标 ```