File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ function render_token_row( WP_User $user, Access_Token $token ) {
8585 sprintf (
8686 '<button class="button" name="oauth2_revoke" title="%s" value="%s">%s</button> ' ,
8787 $ button_title ,
88- esc_attr ( $ token ->get_key () ),
88+ wp_create_nonce ( ' oauth2_revoke: ' . $ token -> get_key () ) . ' : ' . esc_attr ( $ token ->get_key () ),
8989 esc_html__ ( 'Revoke ' , 'oauth2 ' )
9090 ),
9191 ];
@@ -138,7 +138,18 @@ function handle_revocation( $user_id ) {
138138 return ;
139139 }
140140
141- $ key = wp_unslash ( $ _POST ['oauth2_revoke ' ] );
141+ $ data = wp_unslash ( $ _POST ['oauth2_revoke ' ] ); // WPCS: CSRF OK
142+ if ( strpos ( $ data , ': ' ) === null ) {
143+ return ;
144+ }
145+
146+ // Split out nonce and check it.
147+ list ( $ nonce , $ key ) = explode ( ': ' , $ data , 2 );
148+ if ( ! wp_verify_nonce ( $ nonce , 'oauth2_revoke: ' . $ key ) ) {
149+ wp_nonce_ays ( 'oauth2_revoke ' );
150+ die ();
151+ }
152+
142153 $ token = Access_Token::get_by_id ( $ key );
143154 if ( empty ( $ token ) ) {
144155 var_dump ( $ key , $ token );
You can’t perform that action at this time.
0 commit comments