feat(auth): add abuse protection for login and OIDC flows with consent-based authorization handling
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
import type { AbuseProtectionManager } from './classes.abuseprotectionmanager.js';
|
||||
|
||||
@plugins.smartdata.Manager()
|
||||
export class AbuseWindow extends plugins.smartdata.SmartDataDbDoc<
|
||||
AbuseWindow,
|
||||
plugins.idpInterfaces.data.IAbuseWindow,
|
||||
AbuseProtectionManager
|
||||
> {
|
||||
@plugins.smartdata.unI()
|
||||
public id: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public data: plugins.idpInterfaces.data.IAbuseWindow['data'] = {
|
||||
action: '',
|
||||
identifierHash: '',
|
||||
attemptCount: 0,
|
||||
windowStartedAt: 0,
|
||||
blockedUntil: 0,
|
||||
validUntil: 0,
|
||||
createdAt: 0,
|
||||
updatedAt: 0,
|
||||
};
|
||||
|
||||
public isBlocked(nowArg = Date.now()) {
|
||||
return this.data.blockedUntil > nowArg;
|
||||
}
|
||||
|
||||
public isExpired(nowArg = Date.now()) {
|
||||
return this.data.validUntil < nowArg;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user