Skip to content

Commit 19d592e

Browse files
committed
Revert FIDO/U2F file changes per PR #818 review
FIDO/U2F files will be removed entirely in PR #439, so changes to U2F.php and class-two-factor-fido-u2f-admin.php are unnecessary.
1 parent 7171654 commit 19d592e

2 files changed

Lines changed: 10 additions & 30 deletions

File tree

includes/Yubico/U2F.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,6 @@ class Registration
486486

487487
/** The counter associated with this registration */
488488
public $counter = -1;
489-
490-
/** Whether this is a new registration */
491-
public $new;
492-
493-
/** Timestamp when this registration was last used */
494-
public $last_used;
495489
}
496490

497491
/**

providers/class-two-factor-fido-u2f-admin.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,11 @@ public static function show_user_profile( $user ) {
237237
* @return void|never
238238
*/
239239
public static function catch_submission( $user_id ) {
240-
if ( ! empty( $_REQUEST['do_new_security_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is verified immediately below.
240+
if ( ! empty( $_REQUEST['do_new_security_key'] ) ) {
241241
check_admin_referer( "user_security_keys-{$user_id}", '_nonce_user_security_keys' );
242242

243-
if ( ! isset( $_POST['u2f_response'] ) ) {
244-
return;
245-
}
246-
247243
try {
248-
$response = json_decode( wp_unslash( $_POST['u2f_response'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- JSON data decoded immediately.
244+
$response = json_decode( stripslashes( $_POST['u2f_response'] ) );
249245
$reg = Two_Factor_FIDO_U2F::$u2f->doRegister( get_user_meta( $user_id, self::REGISTER_DATA_USER_META_KEY, true ), $response );
250246
$reg->new = true;
251247

@@ -281,8 +277,8 @@ public static function catch_submission( $user_id ) {
281277
public static function catch_delete_security_key() {
282278
$user_id = Two_Factor_Core::current_user_being_edited();
283279

284-
if ( ! empty( $user_id ) && ! empty( $_REQUEST['delete_security_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce requires the slug value, verified immediately below.
285-
$slug = sanitize_text_field( wp_unslash( $_REQUEST['delete_security_key'] ) );
280+
if ( ! empty( $user_id ) && ! empty( $_REQUEST['delete_security_key'] ) ) {
281+
$slug = $_REQUEST['delete_security_key'];
286282

287283
check_admin_referer( "delete_security_key-{$slug}", '_nonce_delete_security_key' );
288284

@@ -301,10 +297,10 @@ public static function catch_delete_security_key() {
301297
* @access public
302298
* @static
303299
*
304-
* @param object $item The current item.
300+
* @param array $item The current item.
305301
* @return string
306302
*/
307-
public static function rename_link( $item ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Required by WP_List_Table column callback interface.
303+
public static function rename_link( $item ) {
308304
return sprintf( '<a href="#" class="editinline">%s</a>', esc_html__( 'Rename', 'two-factor' ) );
309305
}
310306

@@ -316,7 +312,7 @@ public static function rename_link( $item ) { // phpcs:ignore Generic.CodeAnalys
316312
* @access public
317313
* @static
318314
*
319-
* @param object $item The current item.
315+
* @param array $item The current item.
320316
* @return string
321317
*/
322318
public static function delete_link( $item ) {
@@ -349,23 +345,13 @@ public static function wp_ajax_inline_save() {
349345
wp_die();
350346
}
351347

352-
$key = null;
353-
foreach ( $security_keys as $security_key ) {
354-
if ( $security_key->keyHandle === $_POST['keyHandle'] ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
355-
$key = $security_key;
348+
foreach ( $security_keys as &$key ) {
349+
if ( $key->keyHandle === $_POST['keyHandle'] ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
356350
break;
357351
}
358352
}
359353

360-
if ( ! $key ) {
361-
wp_die();
362-
}
363-
364-
if ( ! isset( $_POST['name'] ) ) {
365-
wp_die();
366-
}
367-
368-
$key->name = sanitize_text_field( wp_unslash( $_POST['name'] ) );
354+
$key->name = $_POST['name'];
369355

370356
$updated = Two_Factor_FIDO_U2F::update_security_key( $user_id, $key );
371357
if ( ! $updated ) {

0 commit comments

Comments
 (0)