mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-01-10 22:18:14 +00:00
jwt 配置移动到base
This commit is contained in:
parent
5f8036c365
commit
e7177e27a6
@ -12,5 +12,17 @@ export default (app: Application) => {
|
||||
description: '基础的权限管理功能,包括登录,权限校验',
|
||||
// 中间件
|
||||
globalMiddlewares: ['baseAuthorityMiddleware', 'baseLogMiddleware'],
|
||||
// jwt 生成解密token的
|
||||
jwt: {
|
||||
// 注意: 最好重新修改,防止破解
|
||||
secret: 'FOAPOFALOEQIPNNLQ',
|
||||
// token
|
||||
token: {
|
||||
// 2小时过期,需要用刷新token
|
||||
expire: 2 * 3600,
|
||||
// 15天内,如果没操作过就需要重新登录
|
||||
refreshExpire: 24 * 3600 * 15,
|
||||
},
|
||||
},
|
||||
} as ModuleConfig;
|
||||
};
|
||||
|
||||
@ -17,6 +17,9 @@ export class BaseAuthorityMiddleware implements IWebMiddleware {
|
||||
@Config('cool')
|
||||
coolConfig: CoolConfig;
|
||||
|
||||
@Config('module.base')
|
||||
jwtConfig: CoolConfig;
|
||||
|
||||
coolCache;
|
||||
|
||||
@App()
|
||||
@ -33,7 +36,7 @@ export class BaseAuthorityMiddleware implements IWebMiddleware {
|
||||
// 路由地址为 admin前缀的 需要权限校验
|
||||
if (_.startsWith(url, adminUrl)) {
|
||||
try {
|
||||
ctx.admin = jwt.verify(token, this.coolConfig.jwt.secret);
|
||||
ctx.admin = jwt.verify(token, this.jwtConfig.jwt.secret);
|
||||
} catch (err) {}
|
||||
// 不需要登录 无需权限校验
|
||||
if (new RegExp(`^${adminUrl}?.*/open/`).test(url)) {
|
||||
|
||||
@ -44,7 +44,7 @@ export class BaseSysLoginService extends BaseService {
|
||||
@Inject()
|
||||
ctx: Context;
|
||||
|
||||
@Config('cool')
|
||||
@Config('module.base')
|
||||
coolConfig: CoolConfig;
|
||||
|
||||
/**
|
||||
|
||||
@ -57,18 +57,7 @@ export default (appInfo: EggAppInfo) => {
|
||||
},
|
||||
// 单点登录
|
||||
sso: false,
|
||||
// jwt 生成解密token的
|
||||
jwt: {
|
||||
// 注意: 最好重新修改,防止破解
|
||||
secret: 'FOAPOFALOEQIPNNLQ',
|
||||
// token
|
||||
token: {
|
||||
// 2小时过期,需要用刷新token
|
||||
expire: 2 * 3600,
|
||||
// 15天内,如果没操作过就需要重新登录
|
||||
refreshExpire: 24 * 3600 * 15,
|
||||
},
|
||||
},
|
||||
|
||||
// 分页配置
|
||||
page: {
|
||||
// 分页查询每页条数
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user