mirror of
https://github.com/certd/certd.git
synced 2026-07-15 18:27:33 +08:00
feat: 支持审计日志,操作日志
This commit is contained in:
@@ -40,6 +40,8 @@ export class AuthorityMiddleware implements IWebMiddleware {
|
||||
await next();
|
||||
return;
|
||||
}
|
||||
ctx.auditRouteInfo = routeInfo;
|
||||
this.extractProjectId(ctx);
|
||||
let permission = routeInfo.description || "";
|
||||
permission = permission.trim().split(" ")[0];
|
||||
if (permission == null || permission === "") {
|
||||
@@ -109,6 +111,16 @@ export class AuthorityMiddleware implements IWebMiddleware {
|
||||
return;
|
||||
}
|
||||
|
||||
private extractProjectId(ctx: IMidwayKoaContext) {
|
||||
const headerVal = ctx.headers["project-id"] as string;
|
||||
const queryVal = (ctx.request as any)?.query?.projectId;
|
||||
const bodyVal = (ctx.request as any)?.body?.projectId;
|
||||
const raw = headerVal || queryVal || bodyVal;
|
||||
if (raw != null && raw !== "") {
|
||||
ctx.projectId = parseInt(String(raw), 10) || 0;
|
||||
}
|
||||
}
|
||||
|
||||
private getTokenFromRequest(ctx: IMidwayKoaContext) {
|
||||
let token = ctx.get("Authorization") || "";
|
||||
token = token.replace("Bearer ", "").trim();
|
||||
|
||||
Reference in New Issue
Block a user