Fixes to MFAs

This commit is contained in:
Adolfo Gómez García 2022-07-29 16:20:14 +02:00
parent 94cf5582e2
commit 93ba05f6cb
4 changed files with 27 additions and 20 deletions

View File

@ -212,13 +212,17 @@ class Authenticators(ModelHandler):
self, fields: typing.Dict[str, typing.Any]
) -> None: # pylint: disable=too-many-branches,too-many-statements
logger.debug(self._params)
try:
mfa = MFA.objects.get(
uuid=processUuid(fields['mfa_id'])
)
fields['mfa_id'] = mfa.id
except Exception: # not found
del fields['mfa_id']
if fields['mfa_id']:
try:
mfa = MFA.objects.get(
uuid=processUuid(fields['mfa_id'])
)
fields['mfa_id'] = mfa.id
return
except MFA.DoesNotExist:
pass # will set field to null
fields['mfa_id'] = None

View File

@ -107,10 +107,9 @@ class InternalDBAuth(auths.Authenticator):
def mfaIdentifier(self, username: str) -> str:
try:
self.dbAuthenticator().users.get(name=username, state=State.ACTIVE).mfaData
except Exception:
pass
return ''
return self.dbAuthenticator().users.get(name=username, state=State.ACTIVE).mfaData
finally:
return ''
def transformUsername(self, username: str) -> str:
if self.differentForEachHost.isTrue():

View File

@ -141,7 +141,7 @@ class SMSMFA(mfas.MFA):
label=_('SMS response OK regex'),
order=30,
tooltip=_(
'Regex for SMS response OK. If emty, the response is considered OK if status code is 200.'
'Regex for SMS response OK. If empty, the response is considered OK if status code is 200.'
),
required=False,
tab=_('HTTP Response'),
@ -183,7 +183,7 @@ class SMSMFA(mfas.MFA):
rows=5,
order=32,
tooltip=_('Networks for SMS authentication'),
required=True,
required=False,
tab=_('Config'),
)
@ -222,6 +222,10 @@ class SMSMFA(mfas.MFA):
)
# Any other value means no authentication
# If set ignoreCertificateErrors, do it
if self.ignoreCertificateErrors.isTrue():
session.verify = False
# Add headers. Headers are in the form of "Header: Value". (without the quotes)
if self.headersParameters.value.strip():
for header in self.headersParameters.value.split('\n'):

View File

@ -49,7 +49,7 @@ downloadsManager().registerDownloadable(
_(
'UDS Actor for Debian, Ubuntu, ... Linux machines <b>(Requires python >= 3.6)</b>'
),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/udsactor_{version}_all.deb'.format(version=VERSION),
'application/x-debian-package',
)
@ -59,7 +59,7 @@ downloadsManager().registerDownloadable(
_(
'UDS Actor for Centos, Fedora, RH, Suse, ... Linux machines <b>(Requires python >= 3.6)</b>'
),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/udsactor-{version}-1.noarch.rpm'.format(version=VERSION),
'application/x-redhat-package-manager',
)
@ -69,7 +69,7 @@ downloadsManager().registerDownloadable(
_(
'UDS Actor for Debian based Linux machines. Used ONLY for static machines. <b>(Requires python >= 3.6)</b>'
),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/udsactor-unmanaged_{version}_all.deb'.format(version=VERSION),
'application/x-debian-package',
)
@ -79,7 +79,7 @@ downloadsManager().registerDownloadable(
_(
'UDS Actor for Centos, Fedora, RH, Suse, ... Linux machines. Used ONLY for static machines. <b>(Requires python >= 3.6)</b>'
),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/udsactor-unmanaged-{version}-1.noarch.rpm'.format(version=VERSION),
'application/x-redhat-package-manager',
)
@ -89,7 +89,7 @@ downloadsManager().registerDownloadable(
_(
'<b>Legacy</b> UDS Actor for Debian, Ubuntu, ... Linux machines <b>(Requires python 2.7)</b>'
),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/udsactor_2.2.0_legacy.deb',
'application/x-debian-package',
)
@ -99,7 +99,7 @@ downloadsManager().registerDownloadable(
_(
'<b>Legacy</b> UDS Actor for Centos, Fedora, RH, ... Linux machines <b>(Requires python 2.7)</b>'
),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/udsactor-legacy-2.2.1-1.noarch.rpm',
'application/x-redhat-package-manager',
)
@ -109,7 +109,7 @@ downloadsManager().registerDownloadable(
_(
'<b>Legacy</b> UDS Actor for OpenSUSE, ... Linux machines <b>(Requires python 2.7)</b>'
),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/udsactor-opensuse-legacy-2.2.1-1.noarch.rpm',
'application/x-redhat-package-manager',
)