unify totp check

the totp check is done in several places causing errors like 3552232e99

* ldap (addon)
* accesscontrol (dashboard)
* proxyauth
* directoryserver (exposed ldap)
* externalldap (the connector)

The code also makes externalldap auto-create work now across all the cases where there is a username
This commit is contained in:
Girish Ramakrishnan
2023-03-12 15:09:20 +01:00
parent 8e0d1b61af
commit 53e9eccf72
11 changed files with 103 additions and 147 deletions

View File

@@ -54,25 +54,25 @@ describe('App passwords', function () {
});
it('can verify app password', async function () {
const result = await users.verify(admin.id, password, 'appid');
const result = await users.verify(admin.id, password, 'appid', {});
expect(result).to.be.ok();
expect(result.appPassword).to.be(true);
});
it('can verify non-app password', async function () {
const result = await users.verify(admin.id, admin.password, 'appid');
const result = await users.verify(admin.id, admin.password, 'appid', {});
expect(result).to.be.ok();
expect(result.appPassword).to.be(undefined);
});
it('cannot verify bad password', async function () {
const [error, result] = await safe(users.verify(admin.id, 'bad', 'appid'));
const [error, result] = await safe(users.verify(admin.id, 'bad', 'appid', {}));
expect(result).to.not.be.ok();
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
});
it('cannot verify password for another app', async function () {
const [error, result] = await safe(users.verify(admin.id, password, 'appid2'));
const [error, result] = await safe(users.verify(admin.id, password, 'appid2', {}));
expect(result).to.not.be.ok();
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
});
@@ -82,7 +82,7 @@ describe('App passwords', function () {
});
it('cannot verify deleted app password', async function () {
const [error] = await safe(users.verify(admin.id, password, 'appid'));
const [error] = await safe(users.verify(admin.id, password, 'appid', {}));
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
});