Skip to content

Commit b618216

Browse files
committed
Correct inline documentation
1 parent fccbfc9 commit b618216

File tree

2 files changed

+64
-7
lines changed

2 files changed

+64
-7
lines changed

authorize-page.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
<?php
2+
/**
3+
* Authorization page handler
4+
*
5+
* Takes care of UI and related elements for the authorization step of OAuth.
6+
*
7+
* @package WordPress
8+
* @subpackage JSON API
9+
*/
210

311
class WP_JSON_Authentication_Authorize {
12+
/**
13+
* Request token for the current authorization request
14+
*
15+
* @var array
16+
*/
17+
protected $token;
18+
19+
/**
20+
* Consumer post object for the current authorization request
21+
*
22+
* @var WP_Post
23+
*/
24+
protected $consumer;
25+
26+
/**
27+
* Register required actions and filters
28+
*/
429
public function register_hooks() {
530
add_action( 'login_form_oauth1_authorize', array( $this, 'render_page' ) );
631
add_action( 'oauth1_authorize_form', array( $this, 'page_fields' ) );
732
}
833

34+
/**
35+
* Render authorization page
36+
*
37+
* Callback for login form hook. Must exit.
38+
*/
939
public function render_page() {
1040
// Check required fields
1141
if ( empty( $_REQUEST['oauth_token'] ) ) {
@@ -49,11 +79,22 @@ public function render_page() {
4979
exit;
5080
}
5181

52-
public function page_fields( $consumer ) {
82+
/**
83+
* Output required hidden fields
84+
*
85+
* Outputs the required hidden fields for the authorization page, including
86+
* nonce field.
87+
*/
88+
public function page_fields() {
5389
echo '<input type="hidden" name="consumer" value="' . absint( $consumer->ID ) . '" />';
5490
wp_nonce_field( 'json_oauth1_authorize' );
5591
}
5692

93+
/**
94+
* Display an error using login page wrapper
95+
*
96+
* @param WP_Error $error Error object
97+
*/
5798
public function display_error( WP_Error $error ) {
5899
login_header( __( 'Error' ), '', $error );
59100
?>

lib/class-wp-json-authentication-oauth1.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ public function authenticate( $user ) {
158158
return $user;
159159
}
160160

161+
/**
162+
* Serve an OAuth request
163+
*
164+
* Either returns data to be served, or redirects and exits. Non-reentrant
165+
* for the `authorize` route.
166+
*
167+
* @param string $route Type of request; `authorize`, `request` or `access`
168+
* @return mixed Response data (typically WP_Error or an array). May exit.
169+
*/
161170
public function dispatch( $route ) {
162171
// if ( $_SERVER['REQUEST_METHOD'] !== 'POST' ) {
163172
// return new WP_Error( 'oauth1_invalid_method', __( 'Invalid request method for OAuth endpoint' ), array( 'status' => 405 ) );
@@ -270,12 +279,8 @@ public function get_request_token( $key ) {
270279
/**
271280
* Generate a new request token
272281
*
273-
* @param string $oauth_consumer_key
274-
* @param string $oauth_signature
275-
* @param string $oauth_signature_method
276-
* @param string $oauth_nonce
277-
* @param int $oauth_timestamp
278-
* @return array
282+
* @param array $params Request parameters, from {@see get_parameters}
283+
* @return array|WP_Error Array of token data on success, error otherwise
279284
*/
280285
public function generate_request_token( $params ) {
281286
$consumer = $this->get_consumer( $params['oauth_consumer_key'] );
@@ -328,10 +333,21 @@ public function authorize_request_token( $key ) {
328333
return true;
329334
}
330335

336+
/**
337+
* Delete a request token
338+
*
339+
* @param string $key Token ID
340+
*/
331341
public function remove_request_token( $key ) {
332342
delete_option( 'oauth1_request_' . $key );
333343
}
334344

345+
/**
346+
* Retrieve an access token's data
347+
*
348+
* @param string $oauth_token Token ID
349+
* @return array|null Token data on success, null otherwise
350+
*/
335351
public function get_access_token( $oauth_token ) {
336352
$data = get_option( 'oauth1_access_' . $oauth_token, null );
337353
if ( empty( $data ) ) {

0 commit comments

Comments
 (0)