Example #1
0
 def authenticate(self, username, password):
     if not django_settings.TACACSPLUS_HOST:
         return None
     if not feature_enabled('enterprise_auth'):
         logger.error(
             "Unable to authenticate, license does not support TACACS+ authentication"
         )
         return None
     try:
         # Upstream TACACS+ client does not accept non-string, so convert if needed.
         auth = tacacs_plus.TACACSClient(
             django_settings.TACACSPLUS_HOST.encode('utf-8'),
             django_settings.TACACSPLUS_PORT,
             django_settings.TACACSPLUS_SECRET.encode('utf-8'),
             timeout=django_settings.TACACSPLUS_SESSION_TIMEOUT,
         ).authenticate(
             username.encode('utf-8'),
             password.encode('utf-8'),
             authen_type=tacacs_plus.TAC_PLUS_AUTHEN_TYPES[
                 django_settings.TACACSPLUS_AUTH_PROTOCOL],
         )
     except Exception as e:
         logger.exception("TACACS+ Authentication Error: %s" %
                          (e.message, ))
         return None
     if auth.valid:
         return _get_or_set_enterprise_user(username, password, 'tacacs+')
Example #2
0
 def authenticate(self, request, username, password):
     if not django_settings.TACACSPLUS_HOST:
         return None
     try:
         # Upstream TACACS+ client does not accept non-string, so convert if needed.
         auth = tacacs_plus.TACACSClient(
             django_settings.TACACSPLUS_HOST,
             django_settings.TACACSPLUS_PORT,
             django_settings.TACACSPLUS_SECRET,
             timeout=django_settings.TACACSPLUS_SESSION_TIMEOUT,
         ).authenticate(username, password, authen_type=tacacs_plus.TAC_PLUS_AUTHEN_TYPES[django_settings.TACACSPLUS_AUTH_PROTOCOL])
     except Exception as e:
         logger.exception("TACACS+ Authentication Error: %s" % str(e))
         return None
     if auth.valid:
         return _get_or_set_enterprise_user(username, password, 'tacacs+')