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 {
hooks: {
'@latus/core/config': () => ({
keys: ['ip'],
http: {
keys: ['ip'],
points: 60,
duration: 30,
ttl: 30,
},
socket: {
keys: ['ip'],
points: 60,
duration: 30,
ttl: 30,
},
}),
},
};
export default {};

View File

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

View File

@ -7,11 +7,26 @@ export {default as createLimiter} from './limiter';
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,
},
}),
'@latus/db/server/models': gatherWithLatus(
require.context('./models', false, /\.js$/),
),
'@latus/http/request': (latus) => {
const {config: {'@latus/governor': {http}}} = latus;
const {config: {'@latus/governor/server': {http}}} = latus;
const limiter = createLimiter(latus, {
keyPrefix: '@latus/http/request',
...http,
@ -43,7 +58,7 @@ export default {
};
},
'@latus/socket/authenticate': (latus) => {
const {config: {'@latus/governor': {socket}}} = latus;
const {config: {'@latus/governor/server': {socket}}} = latus;
const limiter = createLimiter(latus, {
keyPrefix: '@latus/socket/authenticate',
...socket,