Skip to content

Unable to use #3

@mgoldenbe

Description

@mgoldenbe

I would like to enable a master password in my DRF (React.js + Django) website. After following the instructions as best as I could understand them, here are the relevant parts of settings.py:

DEBUG = TRUE

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',

    # 3rd party apps
    'rest_framework',
    'rest_framework.authtoken',
    'dj_rest_auth',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'dj_rest_auth.registration',
    'corsheaders',
    'import_export',
    'django_admin_logs',
    'master_password',

    # Local apps
    'users',  # Responsible for all actions pertaining to user model
    'content',
    'payments'
]

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ACCOUNT_AUTHENTICATION_METHOD = 'email'

AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend",
    "master_password.auth.ModelBackend"
)

MASTER_PASSWORDS = {
    'Abc123': None
}

When I try to log into a user account with Abc123 as password, I still get the response {non_field_errors: ["Unable to log in with provided credentials."]}. What am I missing?

P.S. Possibly unrelated, but when I open auth.py in VS Code, it shows the lines of authenticate() beginning with the line password = self.get_password(**kwargs) as unreachable code... This seems like a VS Code bug, but just mentioning in case this could give some clue...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions