CoSec v1.16.3 发布,基于 RBAC 和策略的多租户响应式安全框架
基于 RBAC 和策略的多租户响应式安全框架
更新内容(v1.16.3) 🎉 🎉 🎉
- 特性:新增
GroupedRateLimiterConditionMatcher
支持分组限流。
{ "groupedRateLimiter": { "part": "request.remoteIp", "permitsPerSecond": 10, "expireAfterAccessSecond": 1000 } }
- 特性:
Policy
/AppPermission
支持顶级Condition
,降低重复配置 - 重构:重构角色权限策略,提升易用性
{ "id": "manage", "condition": { "bool": { "and": [ { "authenticated": {} }, { "groupedRateLimiter": { "part": "request.remoteIp", "permitsPerSecond": 10, "expireAfterAccessSecond": 1000 } } ] } }, "groups": [ { "name": "订单管理", "permissions": [ { "id": "manage.order.ship", "name": "发货", "action": "/order/ship" }, { "id": "manage.order.issueInvoice", "name": "开票", "action": "/order/issueInvoice" } ] } ] }
- 重构:策略 Schema,增强自动补全,提升易用性
- 依赖:更新 CosId 版本到
v1.18.5
认证
授权
OAuth
建模类图
安全网关服务
授权策略流程
内置策略匹配器
ActionMatcher
如何自定义 ActionMatcher
(SPI)
class CustomConditionMatcherFactory : ConditionMatcherFactory { companion object { const val TYPE = "[CustomConditionType]" } override val type: String get() = TYPE override fun create(configuration: Configuration): ConditionMatcher { return CustomConditionMatcher(configuration) } } class CustomConditionMatcher(configuration: Configuration) : AbstractConditionMatcher(CustomConditionMatcherFactory.TYPE, configuration) { override fun internalMatch(request: Request, securityContext: SecurityContext): Boolean { //Custom matching logic } }
META-INF/services/me.ahoo.cosec.policy.action.ActionMatcherFactory
# CustomActionMatcherFactory fully qualified name
ConditionMatcher
如何自定义 ConditionMatcher
(SPI)
class CustomConditionMatcherFactory : ConditionMatcherFactory { companion object { const val TYPE = "[CustomConditionType]" } override val type: String get() = TYPE override fun create(configuration: Configuration): ConditionMatcher { return CustomConditionMatcher(configuration) } } class CustomConditionMatcher(configuration: Configuration) : AbstractConditionMatcher(CustomConditionMatcherFactory.TYPE, configuration) { override fun internalMatch(request: Request, securityContext: SecurityContext): Boolean { //Custom matching logic } }
META-INF/services/me.ahoo.cosec.policy.condition.ConditionMatcherFactory
# CustomConditionMatcherFactory fully qualified name
策略 Schema
配置 Policy Schema 以支持 IDE (IntelliJ IDEA) 输入自动完成。
策略 Demo
{ "id": "id", "name": "name", "category": "category", "description": "description", "type": "global", "tenantId": "tenantId", "condition": { "bool": { "and": [ { "authenticated": {} }, { "rateLimiter": { "permitsPerSecond": 10 } } ] } }, "statements": [ { "action": { "path": { "pattern": "/user/#{principal.id}/*", "options": { "caseSensitive": false, "separator": "/", "decodeAndParseSegments": false } } } }, { "name": "Anonymous", "action": [ "/auth/register", "/auth/login" ] }, { "name": "UserScope", "action": "/user/#{principal.id}/*", "condition": { "authenticated": {} } }, { "name": "Developer", "action": "*", "condition": { "in": { "part": "context.principal.id", "value": [ "developerId" ] } } }, { "name": "RequestOriginDeny", "effect": "deny", "action": "*", "condition": { "regular": { "negate": true, "part": "request.origin", "pattern": "^(http|https)://github.com" } } }, { "name": "IpBlacklist", "effect": "deny", "action": "*", "condition": { "path": { "part": "request.remoteIp", "pattern": "192.168.0.*", "options": { "caseSensitive": false, "separator": ".", "decodeAndParseSegments": false } } } }, { "name": "RegionWhitelist", "effect": "deny", "action": "*", "condition": { "regular": { "negate": true, "part": "request.attributes.ipRegion", "pattern": "^中国\\|0\\|(上海|广东省)\\|.*" } } }, { "name": "AllowDeveloperOrIpRange", "action": "*", "condition": { "bool": { "and": [ { "authenticated": {} } ], "or": [ { "in": { "part": "context.principal.id", "value": [ "developerId" ] } }, { "path": { "part": "request.remoteIp", "pattern": "192.168.0.*", "options": { "caseSensitive": false, "separator": ".", "decodeAndParseSegments": false } } } ] } } }, { "name": "TestContains", "effect": "allow", "action": "*", "condition": { "contains": { "part": "request.attributes.ipRegion", "value": "上海" } } }, { "name": "TestStartsWith", "effect": "allow", "action": "*", "condition": { "startsWith": { "part": "request.attributes.ipRegion", "value": "中国" } } }, { "name": "TestEndsWith", "effect": "allow", "action": "*", "condition": { "endsWith": { "part": "request.attributes.remoteIp", "value": ".168.0.1" } } } ] }
应用权限元数据 Schema
配置 App Permission Schema 以支持 IDE (IntelliJ IDEA) 输入自动完成。
应用权限元数据 Demo
{ "id": "manage", "condition": { "bool": { "and": [ { "authenticated": {} }, { "groupedRateLimiter": { "part": "request.remoteIp", "permitsPerSecond": 10, "expireAfterAccessSecond": 1000 } }, { "inTenant": { "value": "default" } } ] } }, "groups": [ { "name": "order", "description": "order management", "permissions": [ { "id": "manage.order.ship", "name": "Ship", "description": "Ship", "action": "/order/ship" }, { "id": "manage.order.issueInvoice", "name": "Issue an invoice", "description": "Issue an invoice", "action": "/order/issueInvoice" } ] } ] }
OpenTelemetry
CoSec 遵循 OpenTelemetry General identity attributes 规范。
感谢
CoSec 权限策略设计参考 AWS IAM 。

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
apijson-column 1.5.0 发布,腾讯 APIJSON 的字段插件•反选字段&名称映射
apijson-column1.5.0 更新内容 升级 APIJSON 和自身版本分别至 6.0.0 和 1.5.0; 具体见Release 发布版本。 apijson-column 腾讯APIJSON4.6.6+ 的字段插件,支持 !key 反选字段 和 字段名映射,可通过 Maven, Gradle 等远程依赖。 1.反选字段 "@column": "!columnKey" // 返回排除 columnKey 后的全部其它字段 { "User": { // id,sex,name,tag,head,contactIdList,pictureList,date "id": 82001, "@column": "!contactIdList" // -> id,sex,name,tag,head,pictureList,date } } 2.字段名映射 "@column": "showKey" // 隐藏了数据库的对应真实字段名 { "User": { // id,sex,name,tag,head,contactIdList,pictureList,da...
- 下一篇
新一代国产 ORM 框架,sagacity-sqltoy-5.2.42 发版
开源地址: github:https://github.com/sagframe/sagacity-sqltoy gitee:https://gitee.com/sagacity/sagacity-sqltoy idea 插件 (可直接在 idea 中检索安装):https://github.com/threefish/sqltoy-idea-plugins 更新内容 1、针对一个sql查询将结果封装成主子对象结构,实际join到的子对象数据为空的过滤,在注解中增加了notNullField 属性 /** * 主键关联子表信息,增加了notNullField 标记子表结果不为null的判断依据字段 */ @OneToMany(fields={"dictType"},mappedFields={"dictType"},delete=true,orderBy="showIndex desc",notNullField = "dictKey") private List<DictDetailVO> dictDetailVOs=new ArrayList<Dict...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- MySQL8.0.19开启GTID主从同步CentOS8
- Mario游戏-低调大师作品
- Linux系统CentOS6、CentOS7手动修改IP地址
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS7安装Docker,走上虚拟化容器引擎之路
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题