-
Notifications
You must be signed in to change notification settings - Fork 156
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
Ensure that doesn't 'fail open' if existing providers poof. #586
base: master
Are you sure you want to change the base?
Conversation
This also ensures if a user only had U2F enabled, and it's deprecated and removed, that it won't "fail open" for lack of any available methods. If Email is available, shove it in. If not, return an error.
class-two-factor-core.php
Outdated
@@ -413,15 +413,37 @@ public static function get_enabled_providers_for_user( $user = null ) { | |||
if ( empty( $enabled_providers ) ) { | |||
$enabled_providers = array(); | |||
} | |||
$enabled_providers = array_intersect( $enabled_providers, array_keys( $providers ) ); | |||
$enabled_existing_providers = array_intersect( $enabled_providers, array_keys( $providers ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$enabled_existing_providers = array_intersect( $enabled_providers, array_keys( $providers ) ); | |
$enabled_registered_providers = array_intersect( $enabled_providers, array_keys( $providers ) ); |
Would this be more clear that we are talking about enabled providers that are registered?
Possible chance with bad input this changes some test results -- I need to add a test for the use case anyway. |
The return value uses the class as keys, and the object as the value.
TOTP being unconfigured stripped it out otherwise.
Co-authored-by: Timothy Jacobs <[email protected]>
Once this is in, purging u2f from the plugin won't leave users who only had that enabled wide open with no two-factor protection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't test manually, but the code LGTM 👍🏻
This also ensures if a user only had U2F enabled, and it's deprecated and removed, that it won't "fail open" for lack of any available methods.
If Email is available, shove it in. If not, return an error.