Replies: 1 comment
|
BullBoard 组件本身目前没有内置登录/鉴权配置,Midway 侧建议在 比如 basePath 是默认 // src/middleware/bull-board-auth.middleware.ts
import { Middleware, IMiddleware } from '@midwayjs/core';
import { Context, NextFunction } from '@midwayjs/koa';
@Middleware()
export class BullBoardAuthMiddleware implements IMiddleware<Context, NextFunction> {
match(ctx: Context) {
return /^\/ui(\/|$)/.test(ctx.path);
}
resolve() {
return async (ctx: Context, next: NextFunction) => {
// 这里接入你自己的登录态 / session / jwt / basic auth
if (!ctx.user) {
ctx.status = 401;
ctx.body = 'Unauthorized';
return;
}
return next();
};
}
}然后在应用启动时把它注册到全局 middleware,确保它的注册顺序早于 bull-board 的 middleware。如果是生产环境,也建议把 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Describe the problem(描述问题)
BullBoard未内置身份验证,在midwayjs中如何添加针对BullBoard的身份验证?
Midway Versions(Midway 版本)
midway@4
All reactions