LianjiaTech / LianjiaTech/bella-openapi
refactor:将 AK 操作权限校验收口至 AOP 切面
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 239
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
背景
当前 ApikeyService 中,每个写操作方法(reset、updateRole、certify、updateQuota、changeStatus、createByParentCode 等)在方法体开头都显式调用 checkPermission(code, AkOperation.XXX),或直接调用 akPermissionChecker.check(db, operation)。
共约 10 处调用分散在业务方法内,权限校验与业务逻辑耦合,新增操作时存在遗漏校验的风险。
诉求
调研将权限校验抽取为 AOP 切面的可行性,并按结论实施重构:
- 定义注解(如
@RequireAkPermission(operation = AkOperation.RESET)),标注在 Service 或 Controller 方法上 - 切面拦截注解,统一完成"按 code 查 DB → 调 AkPermissionChecker.check"的流程
- 移除 Service 方法内的显式
checkPermission调用
预期影响
- 权限校验逻辑集中在切面,Service 方法职责更单一
- 新增操作只需打注解,消除遗漏校验的风险
- 涉及
ApikeyService中约 10 处调用点的改动,以及新增切面和注解定义
证据
N/A
相关链接
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ApikeyService and locate the roughly 10 explicit checkPermission and akPermissionChecker.check calls for the listed write operations. Investigate whether an annotation and AOP aspect can reliably perform the code lookup and permission check, then confirm that the checks are removed from service methods and all affected operations remain protected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authorization, backend, security
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100