
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
c4accesscontrol
Advanced tools
C4AccessControl是基于RBAC(基于角色权限控制)模型进行设计的权限控制框架(模块),需要配置C4WebService模块进行使用(已内置ACL解析和控制逻辑)。 其中主要概念有:
资源矩阵
权限矩阵
角色
用户
/**
* 资源矩阵配置信息
*/
export interface ACResourceMatrix {
/**
* 最终会设置为path
* TODO: 该处设计不合理,不应该设置为path,应该为资源名或ID
* 增加一个对象来存储包含路径的向量
*/
resource: string;
/**
* 显示名称(省略将为resource)
*/
desc?: string;
/**
* 分组信息(默认值是空字符串)
*/
group ?: string;
/**
* TODO: 这个desc是用于构建UI时给用户展示使用,
* 需要与Java端的实现沟通,并在档案(账户/权限)服务中增加该列的记录
*/
groupDesc?: string;
/**
* 操作(省略将为动作默认方法,如GET对应read)
* TODO: 这里的desc是对action的描述,用于构建UI时给用户展示使用
* 需要与Java端的实现沟通,并在档案(账户/权限)服务中增加该列的记录
*/
action?: {
create ?: actionOp;
read ?: actionOp;
update ?: actionOp;
delete ?: actionOp;
createDesc ?: string;
readDesc ?: string;
updateDesc ?: string;
deleteDesc ?: string;
};
// 查询条件上表示用户标识的参数名
paramUser ?: string;
// body体上表示用户表示的属性名
bodyUser ?: string;
// 后置过滤配置
/**
* TODO: 后置过滤的配置
*/
filters ?: any;
// 是否是静态资源的ACL
staticRes ?: boolean;
// 静态资源ACL的path匹配正则
staticPathReg ?: RegExp;
};
C4AccessControl
说明:C4AccessControl对象,提供资源矩阵上传、权限矩阵下载、用户权限验证功能
路径:./src/C4AccessControl.ts
成员变量:
成员方法:
/**
* 初始化
* @param config C4AccessControlConfig
*/
async init(config: C4AccessControlConfig)
/**
* 获取启用状态
*/
isEnabled()
/**
* 获取初始化状态
*/
isInit()
/**
* 设置权限矩阵
* @param accCfg ACResourceMatrix
*/
addAccCtrlTarget(accCfg : ACResourceMatrix)
/**
* 获取权限组
* @param userID 用户ID
*/
private async getUserRoles(userID : string)
/**
* 获取权限组动作属性
* @param roleName 角色名
* @param resource 资源名
* @param action 动作
*/
private getRolePossession(roleName: string, resource: string, action: string)
/**
* 根据资源名获取资源矩阵
* @param resource
*/
getResourceConfig(resource : string)
/**
* 获取静态资源的资源矩阵
*/
getStaticResourceConfigs()
/**
* 判断权限
* @param resource 权限接口资源名
* @param inObj 入参对象
*/
async AccCtrlAuth(resource: string, user: string, action: string | undefined, paramUser: string | undefined): Promise<{
role : string;
pass : boolean;
user?: string;
}>
/**
* 上传权限矩阵
*/
async updateAclMatrix()
/**
* 启动
*/
async launch()
/**
* 重置
*/
async reset()
ACLCache
说明:ACL的Cache接口对象
路径:./src/C4AccessControlTypes/C4AccessControlConfig.ts
成员变量:无
成员方法:
ACLCommunicator
说明:ACL的通讯接口对象
路径:./src/C4AccessControlTypes/C4AccessControlConfig.ts
成员变量:无
成员方法:
ACLDefaultCache
说明:测试用的Cache,在内存中存储
路径:./src/C4AccessControlUtils/ACLDefaultCache.ts
成员变量:
成员方法:同ACLCache
ACLRedisCache
说明:Redis Cache,在Redis中存储
路径:./src/C4AccessControlUtils/ACLRedisCache.ts
成员变量:
成员方法:同ACLCache
ACLDemoCommunicator
说明:用于提交和同步资源矩阵、权限矩阵的Communicator的Demo
路径:./src/C4AccessControlUtils/ACLDemoCommunicator.ts
成员变量:
成员方法:同ACLCommunicator
FAQs
C4Framework Web Service Access Control
The npm package c4accesscontrol receives a total of 9 weekly downloads. As such, c4accesscontrol popularity was classified as not popular.
We found that c4accesscontrol demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.