chore: pre publish

pull/21/merge
xiaojunnuo 2023-05-25 13:43:32 +08:00
parent 420b835b09
commit 998200e570
7 changed files with 22 additions and 12 deletions

View File

@ -0,0 +1 @@
CERTD_AUTH_JWT_KEYS=certd666

View File

@ -45,6 +45,7 @@
"@midwayjs/validate": "^3.9.0",
"cache-manager": "^3.6.3",
"dayjs": "^1.11.7",
"dotenv": "^16.0.3",
"glob": "^7.2.3",
"jsonwebtoken": "^8.5.1",
"kubernetes-client": "^9.0.0",

View File

@ -7,10 +7,18 @@ import { PipelineEntity } from '../modules/pipeline/entity/pipeline';
export default {
// use for cookie sign key, should change to your own and keep security
keys: 'certd666',
keys: process.env.CERTD_AUTH_JWT_KEYS,
koa: {
port: 7001,
},
staticFile: {
dirs: {
default: {
prefix: '/',
dir: 'public',
},
},
},
cron: {},
/**
*
@ -54,11 +62,11 @@ export default {
biz: {
jwt: {
secret: 'greper-is-666',
secret: process.env.CERTD_AUTH_JWT_KEYS,
expire: 7 * 24 * 60, //单位秒
},
auth: {
ignoreUrls: ['/', '/api/login', '/api/register'],
ignoreUrls: ['/', '/public', '/api/login', '/api/register'],
},
},
} as MidwayConfig;

View File

@ -6,5 +6,5 @@ export default {
*/
preview: {
enabled: true,
}
},
} as MidwayConfig;

View File

@ -6,5 +6,5 @@ export default {
*/
preview: {
enabled: true,
}
},
} as MidwayConfig;

View File

@ -15,9 +15,12 @@ import { PreviewMiddleware } from './middleware/preview';
import { AuthorityMiddleware } from './middleware/authority';
import * as staticFile from '@midwayjs/static-file';
import * as cron from './plugins/cron';
import * as dotenv from 'dotenv';
// load .env file in process.cwd
dotenv.config();
@Configuration({
imports: [koa, orm, cache, flyway, validateComp, cron,staticFile],
imports: [koa, orm, cache, flyway, validateComp, cron, staticFile],
importConfigs: [
{
default: defaultConfig,

View File

@ -1,9 +1,5 @@
import { Config, Provide } from '@midwayjs/decorator';
import {
IWebMiddleware,
IMidwayKoaContext,
NextFunction
} from '@midwayjs/koa';
import { IWebMiddleware, IMidwayKoaContext, NextFunction } from '@midwayjs/koa';
import * as _ from 'lodash';
import * as jwt from 'jsonwebtoken';
import { Constants } from '../basic/constants';
@ -21,7 +17,8 @@ export class AuthorityMiddleware implements IWebMiddleware {
resolve() {
return async (ctx: IMidwayKoaContext, next: NextFunction) => {
const { url } = ctx;
const token = ctx.get('Authorization');
let token = ctx.get('Authorization') || '';
token = token.replace('Bearer ', '').trim();
// 路由地址为 admin前缀的 需要权限校验
// console.log('ctx', ctx);
const queryIndex = url.indexOf('?');