Code Monkey home page Code Monkey logo

Comments (5)

clokep avatar clokep commented on July 20, 2024

Thanks @pjensen000! Any chance you can provide this as a PR?

from django-allauth-2fa.

pjensen000 avatar pjensen000 commented on July 20, 2024

Sorry, I don't have any git tools installed or knowledge on how to use them. I just wanted to share the issue report.

from django-allauth-2fa.

dicato avatar dicato commented on July 20, 2024

@pjensen000 / @hailkomputer do you have steps to recreate and test this? Your analysis makes sense but I would prefer to confirm the proposed fix before publishing it.

from django-allauth-2fa.

pjensen000 avatar pjensen000 commented on July 20, 2024

Steps to recreate:
0) assume we are using Django session authentication

  1. Create any user that does not need TFA to login (user 1)
  2. Create an admin user who does need TFA to login and has admin site access (user 2)
  3. Login as user 1
  4. browse directly to your admin site login url (htttps://mysite.com/admin/)
  5. Since you are already logged in as user 1, the login_required mixin does not stop you from seeing the login page
  6. login to the admin site using the default admin login screen which requires username/password but does not prompt for TFA

I can verify that I did this and was able to get in using the login_required decorator. I can also verify that I switched to staff_member_required and now only people already logged in as staff can see the login screen.

Technically, if some staff don't have/need TFA and others do, you could still bypass TFA by logging in as a staff who doesn't have TFA and then doing the same procedure as above. In my case all staff are required to have TFA. The fix only works if all staff are required to use TFA.

A more universal fix would be to write a mixin like staff_member_required except instead it's tfa_enabled_user_required. I have not written such a mixin.

from django-allauth-2fa.

akx avatar akx commented on July 20, 2024

django-otp (used by this library) also sets a session key to denote a session has been OTP'd. That should be also checked by middleware/decorators...

https://github.com/django-otp/django-otp/blob/cd8429869ff580d3ae70da0cba3f615d95fcc6a6/src/django_otp/__init__.py#L25-L27

from django-allauth-2fa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.