CoSec v1.10.1 发布,基于 RBAC 和策略的多租户响应式安全框架


CoSec

基于 RBAC 和策略的多租户响应式安全框架。

License GitHub release Maven Central Codacy Badge codecov Integration Test Status

更新内容(v1.10.1) 🎉 🎉 🎉

  • 特性:新增  ContainsConditionMatcher

  • {
    "name": "TestContains",
    "effect": "allow",
    "actions": [
    {
    "type": "all"
    }
    ],
    "condition": {
    "type": "contains",
    "part": "request.attributes.ipRegion",
    "pattern": "上海"
    }
    }

认证

Authentication-Flow

授权

Authorization-Flow

OAuth

OAuth-Flow

建模类图

Modeling

安全网关服务

Gateway

授权策略流程

Authorization Policy

内置策略匹配器

ActionMatcher

ActionMatcher

如何自定义 ActionMatcher (SPI)

参考 RegularActionMatcher

class CustomActionMatcherFactory : ActionMatcherFactory {
companion object {
const val TYPE = "[CustomActionType]"
}

override val type: String
get() = TYPE

override fun create(onfiguration: Configuration): ActionMatcher {
return CustomActionMatcher(onfiguration)
}
}
class CustomActionMatcher(configuration: Configuration) :
AbstractActionMatcher(CustomActionMatcherFactory.TYPE, configuration) {
override val type: String
get() = CustomActionMatcherFactory.TYPE

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

如何自定义 ConditionMatcher (SPI)

参考 ContainsConditionMatcher

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) :
AbstractActionMatcher(CustomActionMatcherFactory.TYPE, configuration) {
override val type: String
get() = CustomConditionMatcherFactory.TYPE

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

策略 Demo

{
"id": "id",
"name": "name",
"category": "category",
"description": "description",
"type": "global",
"tenantId": "tenantId",
"statements": [
{
"name": "Anonymous",
"effect": "allow",
"actions": [
{
"type": "path",
"pattern": "/auth/register"
},
{
"type": "path",
"pattern": "/auth/login"
}
]
},
{
"name": "UserScope",
"effect": "allow",
"actions": [
{
"type": "path",
"pattern": "/user/#{principal.id}/*"
}
],
"condition": {
"type": "authenticated"
}
},
{
"name": "Developer",
"effect": "allow",
"actions": [
{
"type": "all"
}
],
"condition": {
"type": "in",
"part": "context.principal.id",
"in": [
"developerId"
]
}
},
{
"name": "RequestOriginDeny",
"effect": "deny",
"actions": [
{
"type": "all"
}
],
"condition": {
"type": "reg",
"negate": true,
"part": "request.origin",
"pattern": "^(http|https)://github.com"
}
},
{
"name": "IpBlacklist",
"effect": "deny",
"actions": [
{
"type": "all"
}
],
"condition": {
"type": "path",
"part": "request.remoteIp",
"path": {
"caseSensitive": false,
"separator": ".",
"decodeAndParseSegments": false
},
"pattern": "192.168.0.*"
}
},
{
"name": "RegionWhitelist",
"effect": "deny",
"actions": [
{
"type": "all"
}
],
"condition": {
"negate": true,
"type": "reg",
"part": "request.attributes.ipRegion",
"pattern": "^中国\\|0\\|(上海|广东省)\\|.*"
}
},
{
"name": "AllowDeveloperOrIpRange",
"effect": "allow",
"actions": [
{
"type": "all"
}
],
"condition": {
"type": "bool",
"bool": {
"and": [
{
"type": "authenticated"
}
],
"or": [
{
"type": "in",
"part": "context.principal.id",
"in": [
"developerId"
]
},
{
"type": "path",
"part": "request.remoteIp",
"path": {
"caseSensitive": false,
"separator": ".",
"decodeAndParseSegments": false
},
"pattern": "192.168.0.*"
}
]
}
}
}
]
}

感谢

CoSec 权限策略设计参考 AWS IAM 


相關推薦

2023-01-07

CoSec 基于 RBAC 和策略的多租户响应式安全框架。       更新内容(v1.9.0) 🎉 🎉 🎉 ⭐ 特性 特性:新增  RequestAttributesAppender API。 特性:新增  Ip2RegionRequestAttributesAppender,支持IP区域匹配器。

2023-01-09

CoSec 基于 RBAC 和策略的多租户响应式安全框架。       更新内容(v1.10.0) 🎉 🎉 🎉 ⭐ 更新内容 依赖:更新  io.opentelemetry:opentelemetry-bom 到 v1.22.0。 特性:新增  BoolConditionMatcher

2023-08-19

新详情: 近期在基于 4.14.x 录制视频,新功能开发和版本发布速度会延后,4.14.x 系列主要以优化功能和修复 bug 为主。 build tencentcloud-sdk-java.version>3.1.831 feat (lamp-base): 消息发送 是否成功由实现类自行处理 (lamp-base):

2022-10-01

Snowy是国内首个采用国密技术为核心的前后分离后台权限管理系统,同时也是面向中小企业快速开发平台框架。框架采用主流技术开发设计,支持国产中间件、麒麟操作系统、Windows、Linux部署使用,框架使用SM2、SM3、SM4等国密算

2024-03-14

master Spring Boot 3.2 和 Spring Cloud 2023.0.0 JDK 17 主要发布分支 可使用,但 Spring Cloud Alibaba、Tencent 等生态组件尚未发布正式版本 develop Spring Boot 3.2 和 Spring Cloud 2023.0.0 JDK 17 Development 分支 新功能、ISSUE 均以此分支

2023-09-22

能四世同堂,凭什么开发 30 岁就要被干掉? 红杉资本发布一份报告,总结了这一年生成式AI突飞猛进的发展,探讨了生成式AI的发展趋势和市场表现。 一年前他们发布了一份预测,一年后红杉总结之前的预测,发现了他们预

2023-11-05

更新日志 通用 重新设计创建API流程 mt-ui API界面简化 API详情页重新设计 整体设计优化 bugfix 更多详情 MT-AUTH 是一款多租户权限管理系统,包含用户管理与 API 路由、共享、鉴权、缓存、跨域、安全防护等功能 应

2023-10-27

更新日志 通用 重新设计创建应用流程 mt-sample 同步更新演示代码 mt-access 应用创建重新设计 bugfix mt-integration-test 同步更新测试 mt-ui 应用界面简化 优化项目创建流程 整体设计优化,自动填充字段 bu

2023-11-16

用参数 支持 支持 通知公告 系统通知公告信息发布维护 支持 支持 操作日志 系统正常操作日志记录和查询 系统异常信息日志记录和查询 支持 支持 登录日志 系统登录日志记录查询包含登录异常 支

2024-01-17

4.16.0-java17 增强版更新简介: 代码位于分支: 4.x_java17 feat: 4.x非租户模式首次开源 refactor: 删除无用代码 refactor: database.yml 文件拆分为mysql.yml、oracle.yml、sqlserver.ymlo feat: 新增"查询用户所有应用的可用路由树"接口 refactor:

2023-12-29

4.15.0-java17 增强版更新简介: 代码位于分支: java17 升级内容: 基于xxl-job的定时任务: lamp-job-pro 适配 jdk17 非租户模式,微服务版: lamp-cloud-pro-none 适配jdk17 非租户模式,单体版: lamp-boot-pro-none 适配jdk17 修复代码

2022-09-13

Auth2` 版本。 基于 Vue3、Vite3、Quasar2、Pinia 等新版前端已发布,原有基于 Vue2、Vuetify2、Typescript 开发的前端代码已移至 vue2+vuetify2+typescript 分支 自 2.7.2.3 版本起,Dante Cloud 所有核心代码全部开源。新开放内容包括: 接口权

2023-07-05

基于 DDD、EventSourcing 的现代响应式 CQRS 架构微服务开发框架        领域驱动 | 事件驱动 | 测试驱动 | 声明式设计 | 响应式编程 | 命令查询职责分离 | 事件

2024-03-05

4.17.0 更新简介: refactor: 登录后获取系统路由和资源的接口合并 refactor: 路由接口同时支持vben-admin和soybean-admin fix(lamp-base-biz): 阿里云文件上传后浏览器访问url 文件名乱码 fix(lamp-base-biz): 保存角色资源时,清理缓存忽