mirror of
https://github.com/optim-enterprises-bv/Mailu.git
synced 2025-11-02 11:08:01 +00:00
Introduce AUTH_REQUIRE_TOKENS
This commit is contained in:
@@ -72,6 +72,7 @@ DEFAULT_CONFIG = {
|
||||
'LOGO_URL': None,
|
||||
'LOGO_BACKGROUND': None,
|
||||
# Advanced settings
|
||||
'AUTH_REQUIRE_TOKENS': False,
|
||||
'API': False,
|
||||
'WEB_API': '/api',
|
||||
'API_TOKEN': None,
|
||||
|
||||
@@ -50,8 +50,12 @@ def check_credentials(user, password, ip, protocol=None, auth_port=None, source_
|
||||
app.logger.info(f'Login attempt for: {user}/{protocol}/{auth_port} from: {ip}/{source_port}: failed: badip: token-{token.id}: {token.comment or ""!r}')
|
||||
return False # we can return directly here since the token is valid
|
||||
if user.check_password(password):
|
||||
app.logger.info(f'Login attempt for: {user}/{protocol}/{auth_port} from: {ip}/{source_port}: success: password')
|
||||
return True
|
||||
if app.config['AUTH_REQUIRE_TOKENS'] and protocol != 'web':
|
||||
app.logger.info(f'Login attempt for: {user}/{protocol}/{auth_port} from: {ip}/{source_port}: failed: password but AUTH_REQUIRE_TOKENS=True')
|
||||
return False
|
||||
else:
|
||||
app.logger.info(f'Login attempt for: {user}/{protocol}/{auth_port} from: {ip}/{source_port}: success: password')
|
||||
return True
|
||||
app.logger.info(f'Login attempt for: {user}/{protocol}/{auth_port} from: {ip}/{source_port}: failed: badauth: {utils.truncated_pw_hash(password)}')
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user