refactor(security): governor

This commit is contained in:
cha0s 2021-01-19 10:07:08 -06:00
parent ec18e88e3d
commit 47440a025a
3 changed files with 19 additions and 22 deletions

View File

@ -1,19 +1 @@
export default { export default {};
hooks: {
'@latus/core/config': () => ({
keys: ['ip'],
http: {
keys: ['ip'],
points: 60,
duration: 30,
ttl: 30,
},
socket: {
keys: ['ip'],
points: 60,
duration: 30,
ttl: 30,
},
}),
},
};

View File

@ -4,7 +4,7 @@ import {
} from '@latus/db/server'; } from '@latus/db/server';
export default (latus) => { export default (latus) => {
const {config: {'@latus/governor': {keys}}} = latus; const {config: {'@latus/governor/server': {keys}}} = latus;
return class Ban extends Model { return class Ban extends Model {
static get attributes() { static get attributes() {

View File

@ -7,11 +7,26 @@ export {default as createLimiter} from './limiter';
export default { export default {
hooks: { hooks: {
'@latus/core/config': () => ({
keys: ['ip'],
http: {
keys: ['ip'],
points: 60,
duration: 30,
ttl: 30,
},
socket: {
keys: ['ip'],
points: 60,
duration: 30,
ttl: 30,
},
}),
'@latus/db/server/models': gatherWithLatus( '@latus/db/server/models': gatherWithLatus(
require.context('./models', false, /\.js$/), require.context('./models', false, /\.js$/),
), ),
'@latus/http/request': (latus) => { '@latus/http/request': (latus) => {
const {config: {'@latus/governor': {http}}} = latus; const {config: {'@latus/governor/server': {http}}} = latus;
const limiter = createLimiter(latus, { const limiter = createLimiter(latus, {
keyPrefix: '@latus/http/request', keyPrefix: '@latus/http/request',
...http, ...http,
@ -43,7 +58,7 @@ export default {
}; };
}, },
'@latus/socket/authenticate': (latus) => { '@latus/socket/authenticate': (latus) => {
const {config: {'@latus/governor': {socket}}} = latus; const {config: {'@latus/governor/server': {socket}}} = latus;
const limiter = createLimiter(latus, { const limiter = createLimiter(latus, {
keyPrefix: '@latus/socket/authenticate', keyPrefix: '@latus/socket/authenticate',
...socket, ...socket,