chore: bring everything up2date

This commit is contained in:
simon 2021-01-23 22:14:56 +01:00
parent 4711c385c8
commit 1778948ee2
5 changed files with 3529 additions and 2913 deletions

6389
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -34,27 +34,27 @@
"debug": "^4.3.1", "debug": "^4.3.1",
"imap-simple": "^5.0.0", "imap-simple": "^5.0.0",
"ldapauth-fork": "^5.0.1", "ldapauth-fork": "^5.0.1",
"ldapjs": "^2.2.2", "ldapjs": "^2.2.3",
"native-duplexpair": "^1.0.0", "native-duplexpair": "^1.0.0",
"node-cache": "^5.1.2", "node-cache": "^5.1.2",
"radius": "~1.1.4", "radius": "~1.1.4",
"smtp-client": "^0.3.3", "smtp-client": "^0.3.3",
"yargs": "~16.1.1" "yargs": "~16.2.0"
}, },
"license": "GPLv3", "license": "GPLv3",
"devDependencies": { "devDependencies": {
"@hokify/eslint-config": "^1.0.5", "@hokify/eslint-config": "^1.1.0",
"@types/chai": "^4.2.14", "@types/chai": "^4.2.14",
"@types/ldapjs": "^1.0.9", "@types/ldapjs": "^1.0.9",
"@types/mocha": "^8.0.4", "@types/mocha": "^8.2.0",
"@types/radius": "0.0.28", "@types/radius": "0.0.28",
"@types/yargs": "^15.0.10", "@types/yargs": "^15.0.12",
"chai": "^4.2.0", "chai": "^4.2.0",
"eslint": "^7.14.0", "eslint": "^7.18.0",
"mocha": "^8.2.1", "mocha": "^8.2.1",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"standard-version": "^9.0.0", "standard-version": "^9.1.0",
"ts-node": "^9.0.0", "ts-node": "^9.1.1",
"typescript": "^4.1.2" "typescript": "^4.1.3"
} }
} }

View File

@ -79,7 +79,7 @@ export class GoogleLDAPAuth implements IAuthentication {
return; return;
} }
res.on('searchEntry', function (entry) { res.on('searchEntry', (entry) => {
// log('entry: ' + JSON.stringify(entry.object)); // log('entry: ' + JSON.stringify(entry.object));
usernameFields.forEach((field) => { usernameFields.forEach((field) => {
const index = entry.object[field] as string; const index = entry.object[field] as string;
@ -87,11 +87,11 @@ export class GoogleLDAPAuth implements IAuthentication {
}); });
}); });
res.on('searchReference', function (referral) { res.on('searchReference', (referral) => {
log(`referral: ${referral.uris.join()}`); log(`referral: ${referral.uris.join()}`);
}); });
res.on('error', function (ldapErr) { res.on('error', (ldapErr) => {
console.error(`error: ${JSON.stringify(ldapErr)}`); console.error(`error: ${JSON.stringify(ldapErr)}`);
reject(ldapErr); reject(ldapErr);
}); });
@ -110,7 +110,12 @@ export class GoogleLDAPAuth implements IAuthentication {
this.lastDNsFetch = new Date(); this.lastDNsFetch = new Date();
} }
async authenticate(username: string, password: string, count = 0, forceFetching = false) { async authenticate(
username: string,
password: string,
count = 0,
forceFetching = false
): Promise<boolean> {
const cacheValidTime = new Date(); const cacheValidTime = new Date();
cacheValidTime.setHours(cacheValidTime.getHours() - 12); cacheValidTime.setHours(cacheValidTime.getHours() - 12);
@ -150,7 +155,7 @@ export class GoogleLDAPAuth implements IAuthentication {
authClient.bind(dn, password, (err, res) => { authClient.bind(dn, password, (err, res) => {
if (err) { if (err) {
if (err && (err as any).stack && (err as any).stack.includes(`ldap.google.com closed`)) { if (err && (err as any).stack && (err as any).stack.includes(`ldap.google.com closed`)) {
count++; count += 1;
// wait 1 second to give the ldap error handler time to reconnect // wait 1 second to give the ldap error handler time to reconnect
setTimeout(() => resolve(this.authenticate(dn, password)), 2000); setTimeout(() => resolve(this.authenticate(dn, password)), 2000);
return; return;
@ -167,6 +172,6 @@ export class GoogleLDAPAuth implements IAuthentication {
}); });
}); });
return !!authResult; return authResult;
} }
} }

View File

@ -43,14 +43,14 @@ export class LDAPAuth implements IAuthentication {
searchFilter: config.searchFilter || '(uid={{username}})', searchFilter: config.searchFilter || '(uid={{username}})',
reconnect: true, reconnect: true,
}); });
this.ldap.on('error', function (err) { this.ldap.on('error', (err) => {
console.error('LdapAuth: ', err); console.error('LdapAuth: ', err);
}); });
} }
async authenticate(username: string, password: string) { async authenticate(username: string, password: string): Promise<boolean> {
const authResult: boolean = await new Promise((resolve, reject) => { const authResult: boolean = await new Promise((resolve, reject) => {
this.ldap.authenticate(username, password, function (err, user) { this.ldap.authenticate(username, password, (err, user) => {
if (err) { if (err) {
resolve(false); resolve(false);
console.error('ldap error', err); console.error('ldap error', err);
@ -61,6 +61,6 @@ export class LDAPAuth implements IAuthentication {
}); });
}); });
return !!authResult; return authResult;
} }
} }

View File

@ -86,9 +86,9 @@ export class EAPPacketHandler implements IPacketHandler {
supportedEAPMethods.push(supportedMethod); supportedEAPMethods.push(supportedMethod);
} }
currentState.validMethods = currentState.validMethods.filter((method) => { currentState.validMethods = currentState.validMethods.filter(
return supportedEAPMethods.includes(method.getEAPType()); // kick it out? (method) => supportedEAPMethods.includes(method.getEAPType()) // kick it out?
}); );
// save // save
this.eapConnectionStates.set(stateID, currentState); this.eapConnectionStates.set(stateID, currentState);
@ -101,9 +101,7 @@ export class EAPPacketHandler implements IPacketHandler {
// continue with responding a NAK and add rest of supported methods // continue with responding a NAK and add rest of supported methods
// eslint-disable-next-line no-fallthrough // eslint-disable-next-line no-fallthrough
default: { default: {
const eapMethod = this.eapMethods.find((method) => { const eapMethod = this.eapMethods.find((method) => type === method.getEAPType());
return type === method.getEAPType();
});
if (eapMethod) { if (eapMethod) {
return eapMethod.handleMessage( return eapMethod.handleMessage(