Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two factor not working with django-auth-adfs #694

Open
hrebynakha opened this issue Jan 16, 2024 · 0 comments
Open

Two factor not working with django-auth-adfs #694

hrebynakha opened this issue Jan 16, 2024 · 0 comments

Comments

@hrebynakha
Copy link

hrebynakha commented Jan 16, 2024

Two factor not working with other authentication backend (django-auth-adfs)

Expected Behavior

I'm trying to setup 2fa for application with already configured authentication with django-auth-adfs, and have issue with using it.
Setup with QR code successfully completed, but when i log out from application and login again and try access to the views with OTPRequiredMixin it check my login and cannot process login step

  1. when the login_url configured as django_auth_adfs:login
    login_url = 'django_auth_adfs:login'
    it return error To Many redirects
  2. when the login_url configured as two_facrtort:login
    login_url = 'two_factor:login'
    it return the login form that i can't process (because user doesn't have login\password in application )

Current Behavior

When user already authenticated in application we can check this by request.user.is_authentificated and force step with auth without any input ( username \password form )

Possible Solution

Modification class LoginView, add force step auth for this class if request.user.is_authentificated is True

Steps to Reproduce (for bugs)

  1. Configure ADFS auth in application (https://github.com/snok/django-auth-adfs/tree/master)
  2. Configure django-two-factor-auth
    my settings.py looks like:
INSTALLED_APPS = [
....
    'django_auth_adfs',
.....

    'django_otp',
    'django_otp.plugins.otp_totp',
    'django_otp.plugins.otp_static',
    'two_factor',

]

MIDDLEWARE = [
......
    'django_auth_adfs.middleware.LoginRequiredMiddleware',
    'django_otp.middleware.OTPMiddleware', 
]
AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'django_auth_adfs.backend.AdfsBackend',

)
LOGIN_URL = "django_auth_adfs:login"
LOGIN_REDIRECT_URL = 'two_factor:profile'

  1. Log in in application and setup MFA (when I setup it first time it's works well)
  2. Logout from application
  3. Login again and try to access to view with OTPRequiredMixin and got error with ToMany redirect or got login form

Your Environment

  • Browser and version: Chrome 120.0.6099.217
  • Python version: 3.9
  • Django version: 4.2.7
  • django-otp version: 1.3.0
  • django-two-factor-auth version: 1.15.5
@moggers87 moggers87 changed the title Two factor not working with other authentication backend Two factor not working with django-auth-adfs Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant