Example #1
0
def database_engine(settings_dict):
    """Allow to use aliases for database engines, as well as the default dotted name"""
    engine = _default_database_engines.get(
        settings_dict["DATABASE_ENGINE"].lower(), settings_dict["DATABASE_ENGINE"]
    )
    if engine == "django.db.backends.postgresql":
        try:
            get_distribution("psycopg2-binary")
        except DistributionNotFound:
            try:
                get_distribution("psycopg2")
            except DistributionNotFound:
                settings_check_results.append(
                    missing_package("psycopg2-binary", " to use PostgreSQL database")
                )
    elif engine == "django.db.backends.oracle":
        try:
            get_distribution("cx_Oracle")
        except DistributionNotFound:
            settings_check_results.append(
                missing_package("cx_Oracle", " to use Oracle database")
            )
    elif engine == "django.db.backends.mysql":
        try:
            get_distribution("mysqlclient")
        except DistributionNotFound:
            settings_check_results.append(
                missing_package("mysqlclient", " to use MySQL or MariaDB database")
            )
    return engine
Example #2
0
 def get_requirements(package_name, parent=None):
     try:
         yield str(package_name)
         d = get_distribution(package_name)
         for r in d.requires():
             for required_package in get_requirements(r, parent=package_name):
                 yield str(required_package)
     except DistributionNotFound:
         settings_check_results.append(
             missing_package(str(package_name), " by %s" % parent)
         )
     except VersionConflict:
         settings_check_results.append(
             missing_package(str(package_name), " by %s" % parent)
         )
Example #3
0
 def process_django_allauth(self, settings_dict):
     if (not settings_dict["USE_ALL_AUTH"]
             and not settings_dict["ALLAUTH_PROVIDER_APPS"]):
         return []
     try:
         get_distribution("django-allauth")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-allauth",
                             " to use OAuth2 or OpenID authentication"))
         return []
     if "django.contrib.sites" not in self.default_apps:
         settings_check_results.append(
             Error(
                 '"django.contrib.sites" app must be enabled.',
                 obj="configuration",
                 id="djangofloor.E001",
             ))
         return []
     result = [
         "allauth",
         "allauth.account",
         "allauth.socialaccount",
     ]
     if settings_dict["ALLAUTH_PROVIDER_APPS"]:
         result += [
             k for k in settings_dict["ALLAUTH_PROVIDER_APPS"]
             if k in self.social_apps
         ]
     return result
Example #4
0
 def process_third_parties(self, settings_dict):
     result = []
     for k, v in self.common_third_parties.items():
         package_name = v.partition(".")[0]
         if not settings_dict[k]:
             continue
         elif not is_package_present(package_name):
             settings_check_results.append(missing_package(package_name, ""))
             continue
         result.append(v)
     return result
Example #5
0
 def process_django_ldap(self, settings_dict):
     if not settings_dict["AUTH_LDAP_SERVER_URI"]:
         return []
     try:
         get_distribution("django-auth-ldap")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-auth-ldap", " to use LDAP authentication")
         )
         return []
     return ["django_auth_ldap.backend.LDAPBackend"]
Example #6
0
 def process_radius(self, settings_dict):
     if not settings_dict["RADIUS_SERVER"]:
         return []
     try:
         get_distribution("django-radius")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-radius", " to use RADIUS authentication")
         )
         return []
     return ["radiusauth.backends.RADIUSBackend"]
Example #7
0
 def process_django_ldap(self, settings_dict):
     if not settings_dict["AUTH_LDAP_SERVER_URI"]:
         return []
     try:
         get_distribution("django-auth-ldap")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-auth-ldap",
                             " to use LDAP authentication"))
         return []
     return ["django_auth_ldap.backend.LDAPBackend"]
Example #8
0
 def process_radius(self, settings_dict):
     if not settings_dict["RADIUS_SERVER"]:
         return []
     try:
         get_distribution("django-radius")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-radius",
                             " to use RADIUS authentication"))
         return []
     return ["radiusauth.backends.RADIUSBackend"]
Example #9
0
 def process_pam(self, settings_dict):
     if not settings_dict["USE_PAM_AUTHENTICATION"]:
         return []
     try:
         get_distribution("django_pam")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-pam", " to use PAM authentication"))
         return []
     # check if the current user is in the shadow group
     username = pwd.getpwuid(os.getuid()).pw_name
     if not any(x.gr_name == "shadow" and username in x.gr_mem
                for x in grp.getgrall()):
         settings_check_results.append(
             Error(
                 'The user "%s" must belong to the "shadow" group to use PAM '
                 "authentication." % username,
                 obj="configuration",
             ))
         return []
     return ["django_pam.auth.backends.PAMBackend"]
Example #10
0
 def process_pam(self, settings_dict):
     if not settings_dict["USE_PAM_AUTHENTICATION"]:
         return []
     try:
         get_distribution("django_pam")
     except DistributionNotFound:
         settings_check_results.append(
             missing_package("django-pam", " to use PAM authentication")
         )
         return []
     # check if the current user is in the shadow group
     username = pwd.getpwuid(os.getuid()).pw_name
     if not any(
         x.gr_name == "shadow" and username in x.gr_mem for x in grp.getgrall()
     ):
         settings_check_results.append(
             Error(
                 'The user "%s" must belong to the "shadow" group to use PAM '
                 "authentication." % username,
                 obj="configuration",
             )
         )
         return []
     return ["django_pam.auth.backends.PAMBackend"]