django-two-factor-auth icon indicating copy to clipboard operation
django-two-factor-auth copied to clipboard

[WIP] Pluggable providers

Open Bouke opened this issue 6 years ago • 2 comments

Work in progress for pluggable factor providers.

Motivation and Context

The issue to add additional factor provider comes up frequently. We currently have questions / PRs for adding U2F and e-mail factor providers. Currently this doesn't compose, as the setup / login views become overly complex. This rewrite attempts to improve the situation.

Description

Factor providers can be added as Django apps. Implementers are expected to implement a contract. See the generator / phone number providers as example implementations.

This PR is a very rough draft. There are some areas that need further improvement;

  • the views becoming even more complex, due to all the callbacks on the contract
  • inconsistency in how forms are configured / devices are created, perhaps through a unified interface

There's also some features missing currently:

  • ability to configure backup devices

Some things to resolve:

  • handle db migrations

Extensibility

Both builtin provider implementations contain a subclass of AppConfig. This subclass will be the entry point for further extension. Users of these providers can provide their custom subclass to overwrite the defaults and provide additional functionality.

How Has This Been Tested?

  • PR is not incomplete.
  • Unit tests are broken.

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [x] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ ] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

Bouke avatar Aug 10 '18 07:08 Bouke

@MarkusH @moggers87 I'd be happy to hear your feedback on this early draft.

Bouke avatar Aug 10 '18 08:08 Bouke

I've had a very brief look over the diff, nothing popped out at me that looked bad/horrible/whatever.

Some things to resolve:

  • handle db migrations

What's the issue with migrations?

moggers87 avatar Aug 10 '18 17:08 moggers87

Hey @Bouke, I guess this PR is obsolete now that we have the plugin architecture in master. Many thanks for this work which inspired me for my patches.

claudep avatar Sep 17 '22 13:09 claudep