1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-24 19:07:23 +01:00

Merge remote-tracking branch 'fspoettel/admin-panel-2fa' into totp

# Conflicts:
#	management/auth.py
#	management/mailconfig.py
This commit is contained in:
downtownallday
2020-09-12 19:44:22 -04:00
6 changed files with 43 additions and 28 deletions

View File

@@ -1149,20 +1149,19 @@ def get_mfa_state(email, env):
'mru_token': '' if mru_token is None else mru_token
}
def create_totp_credential(email, secret, token, env):
def create_totp_credential(email, secret, env):
validate_totp_secret(secret)
conn = open_database(env)
user = find_mail_user(env, email, ['objectClass','totpSecret','totpMruToken'], conn)
user = find_mail_user(env, email, ['objectClass','totpSecret'], conn)
if user is None:
return ("That's not a user (%s)." % email, 400)
attrs = {
"totpSecret": secret,
"totpMruToken": token
}
if 'totpUser' not in user['objectClass']:
attrs['objectClass'] = user['objectClass'].copy()
attrs['objectClass'].append('totpUser')
attrs['objectClass'].append('totpUser')
conn.add_or_modify(user['dn'], user, attrs.keys(), None, attrs)
return "OK"