Ошибка при обнаружении модуля в /saml_auth2/acs/

#python #django-saml2-auth

#python #django-saml2-auth

Вопрос:

Я использую Django_Saml2_Auth. Я получаю следующую ошибку.

 ModuleNotFoundError at /saml_auth2/acs/
No module named 'path'

Request Method: POST
https://127.0.0.1:8000/saml_auth2/acs/
3.0.10
ModuleNotFoundError
No module named 'path'
in _find_and_load_unlocked, line 973
/home//workspace//bin/python
3.8.2
  

Используя приведенную ниже конфигурацию:

 SAML2_AUTH = {
    # Metadata is required, choose either remote url or local file path
    'METADATA_AUTO_CONF_URL': 'https://login.microsoftonline.com/xxxx-fa3e-43ab-ad2b-d8f26ba34fda/federationmetadata/2007-06/federationmetadata.xml?appid=xx-4dd1-4429-83d4-xxx',
    'METADATA_LOCAL_FILE_PATH': BASE_DIR / 'Dango_Saml_Auth/Azure AD SAML Toolkit.xml',

    # Optional settings below
    'DEFAULT_NEXT_URL': '/admin',  # Custom target redirect URL after the user get logged in. Default to /admin if not set. This setting will be overwritten if you have parameter ?next= specificed in the login URL.
    'CREATE_USER': 'FALSE', # Create a new Django user when a new user logs in. Defaults to True.
    'NEW_USER_PROFILE': {
        'USER_GROUPS': [],  # The default group name when a new user logs in
        'ACTIVE_STATUS': True,  # The default active status for new users
        'STAFF_STATUS': True,  # The staff status for new users
        'SUPERUSER_STATUS': False,  # The superuser status for new users
    },
    'ATTRIBUTES_MAP': {
        'email': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress',
        'username': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name',
        'first_name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname',
        'last_name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname',
    },
    # 'TRIGGER': {
    # 'CREATE_USER': 'path.to.your.new.user.hook.method',
    # 'BEFORE_LOGIN': 'path.to.your.login.hook.method',
    # },
    'ASSERTION_URL': 'https://127.0.0.1:8000', # Custom URL to validate incoming SAML requests against
    'ENTITY_ID': 'http://samltoolkit/xxxxx-437a-430e-a63a-125f2c210e52', # Populates the Issuer element in authn request
    'NAME_ID_FORMAT': 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient', # Sets the Format property of authn NameIDPolicy element
    'USE_JWT': False, # Set this to True if you are running a Single Page Application (SPA) with Django Rest Framework (DRF), and are using JWT authentication to authorize client users
    'FRONTEND_URL': 'https://localhost:4200', # Redirect URL for the client if you are using JWT auth with DRF. See explanation below
}
  

Я не знаю, что не так в моем коде. файл urls настроен в соответствии с упомянутой документацией.

Ответ №1:

Чтобы устранить проблему, изменил настройки на 'CREATE_USER': 'True'