mirror of https://github.com/certd/certd
chore: pre publish
parent
420b835b09
commit
998200e570
|
@ -0,0 +1 @@
|
||||||
|
CERTD_AUTH_JWT_KEYS=certd666
|
|
@ -45,6 +45,7 @@
|
||||||
"@midwayjs/validate": "^3.9.0",
|
"@midwayjs/validate": "^3.9.0",
|
||||||
"cache-manager": "^3.6.3",
|
"cache-manager": "^3.6.3",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
"glob": "^7.2.3",
|
"glob": "^7.2.3",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"kubernetes-client": "^9.0.0",
|
"kubernetes-client": "^9.0.0",
|
||||||
|
|
|
@ -7,10 +7,18 @@ import { PipelineEntity } from '../modules/pipeline/entity/pipeline';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// use for cookie sign key, should change to your own and keep security
|
// use for cookie sign key, should change to your own and keep security
|
||||||
keys: 'certd666',
|
keys: process.env.CERTD_AUTH_JWT_KEYS,
|
||||||
koa: {
|
koa: {
|
||||||
port: 7001,
|
port: 7001,
|
||||||
},
|
},
|
||||||
|
staticFile: {
|
||||||
|
dirs: {
|
||||||
|
default: {
|
||||||
|
prefix: '/',
|
||||||
|
dir: 'public',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
cron: {},
|
cron: {},
|
||||||
/**
|
/**
|
||||||
* 演示环境
|
* 演示环境
|
||||||
|
@ -54,11 +62,11 @@ export default {
|
||||||
|
|
||||||
biz: {
|
biz: {
|
||||||
jwt: {
|
jwt: {
|
||||||
secret: 'greper-is-666',
|
secret: process.env.CERTD_AUTH_JWT_KEYS,
|
||||||
expire: 7 * 24 * 60, //单位秒
|
expire: 7 * 24 * 60, //单位秒
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
ignoreUrls: ['/', '/api/login', '/api/register'],
|
ignoreUrls: ['/', '/public', '/api/login', '/api/register'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as MidwayConfig;
|
} as MidwayConfig;
|
||||||
|
|
|
@ -6,5 +6,5 @@ export default {
|
||||||
*/
|
*/
|
||||||
preview: {
|
preview: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
}
|
},
|
||||||
} as MidwayConfig;
|
} as MidwayConfig;
|
||||||
|
|
|
@ -6,5 +6,5 @@ export default {
|
||||||
*/
|
*/
|
||||||
preview: {
|
preview: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
}
|
},
|
||||||
} as MidwayConfig;
|
} as MidwayConfig;
|
||||||
|
|
|
@ -15,9 +15,12 @@ import { PreviewMiddleware } from './middleware/preview';
|
||||||
import { AuthorityMiddleware } from './middleware/authority';
|
import { AuthorityMiddleware } from './middleware/authority';
|
||||||
import * as staticFile from '@midwayjs/static-file';
|
import * as staticFile from '@midwayjs/static-file';
|
||||||
import * as cron from './plugins/cron';
|
import * as cron from './plugins/cron';
|
||||||
|
import * as dotenv from 'dotenv';
|
||||||
|
|
||||||
|
// load .env file in process.cwd
|
||||||
|
dotenv.config();
|
||||||
@Configuration({
|
@Configuration({
|
||||||
imports: [koa, orm, cache, flyway, validateComp, cron,staticFile],
|
imports: [koa, orm, cache, flyway, validateComp, cron, staticFile],
|
||||||
importConfigs: [
|
importConfigs: [
|
||||||
{
|
{
|
||||||
default: defaultConfig,
|
default: defaultConfig,
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
import { Config, Provide } from '@midwayjs/decorator';
|
import { Config, Provide } from '@midwayjs/decorator';
|
||||||
import {
|
import { IWebMiddleware, IMidwayKoaContext, NextFunction } from '@midwayjs/koa';
|
||||||
IWebMiddleware,
|
|
||||||
IMidwayKoaContext,
|
|
||||||
NextFunction
|
|
||||||
} from '@midwayjs/koa';
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as jwt from 'jsonwebtoken';
|
import * as jwt from 'jsonwebtoken';
|
||||||
import { Constants } from '../basic/constants';
|
import { Constants } from '../basic/constants';
|
||||||
|
@ -21,7 +17,8 @@ export class AuthorityMiddleware implements IWebMiddleware {
|
||||||
resolve() {
|
resolve() {
|
||||||
return async (ctx: IMidwayKoaContext, next: NextFunction) => {
|
return async (ctx: IMidwayKoaContext, next: NextFunction) => {
|
||||||
const { url } = ctx;
|
const { url } = ctx;
|
||||||
const token = ctx.get('Authorization');
|
let token = ctx.get('Authorization') || '';
|
||||||
|
token = token.replace('Bearer ', '').trim();
|
||||||
// 路由地址为 admin前缀的 需要权限校验
|
// 路由地址为 admin前缀的 需要权限校验
|
||||||
// console.log('ctx', ctx);
|
// console.log('ctx', ctx);
|
||||||
const queryIndex = url.indexOf('?');
|
const queryIndex = url.indexOf('?');
|
||||||
|
|
Loading…
Reference in New Issue