Changeset 3311880
- Timestamp:
- 06/15/2025 11:49:09 AM (10 months ago)
- Location:
- password-protect-pdf
- Files:
-
- 6 edited
- 1 copied
-
tags/1.0.2 (copied) (copied from password-protect-pdf/trunk)
-
tags/1.0.2/includes/process-machine.php (modified) (4 diffs)
-
tags/1.0.2/includes/verification.php (modified) (1 diff)
-
tags/1.0.2/readme.txt (modified) (2 diffs)
-
trunk/includes/process-machine.php (modified) (4 diffs)
-
trunk/includes/verification.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
password-protect-pdf/tags/1.0.2/includes/process-machine.php
r3260525 r3311880 13 13 'methods' => 'POST', 14 14 'callback' => 'cross_service_solutions_password_protect_pdf_on_submit', 15 'permission_callback' => ' __return_true',15 'permission_callback' => 'cross_service_solutions_password_protect_pdf_verify_nonce', 16 16 )); 17 17 register_rest_route('password-protect-pdf/v1', '/status/(?P<id>\d+)', array( 18 18 'methods' => 'GET', 19 19 'callback' => 'cross_service_solutions_password_protect_pdf_check_status', 20 'permission_callback' => ' __return_true',20 'permission_callback' => 'cross_service_solutions_password_protect_pdf_verify_nonce', 21 21 )); 22 22 } 23 23 add_action('rest_api_init', 'cross_service_solutions_password_protect_pdf_register_rest_api'); 24 25 function cross_service_solutions_password_protect_pdf_verify_nonce($request) { 26 $nonce = $request->get_header('X-WP-Nonce'); 27 28 // If not in header, try body 29 if (!$nonce && isset($request['protectPDFFormNonce'])) { 30 $nonce = sanitize_text_field($request['protectPDFFormNonce']); 31 } 32 33 if (!$nonce || !wp_verify_nonce($nonce, 'password_protect_pdf_form_nonce_action')) { 34 return false; 35 } 36 37 return true; 38 } 24 39 25 40 function cross_service_solutions_test_password_protect_pdf_api_callback() { … … 29 44 // Handle form submission, then initiate processing 30 45 function cross_service_solutions_password_protect_pdf_on_submit($request) { 31 // Check if nonce is set and valid32 if (!isset($request['protectPDFFormNonce']) ||33 !wp_verify_nonce($request['protectPDFFormNonce'], 'password_protect_pdf_form_nonce_action')) {34 return new WP_Error('nonce_invalid', 'Nonce verification failed', array('status' => 403, 'message' => $request['protectPDFFormNonce']));35 }36 46 37 47 $api_key = esc_attr(get_option('cross_service_solutions_api_key')); … … 92 102 93 103 // Make the API request using wp_remote_post 94 $response = wp_remote_post('https://api. process-machine-stage.com/solutions/solutions/wordpress/32', array(104 $response = wp_remote_post('https://api.cross-service-solutions.com/solutions/solutions/wordpress/32', array( 95 105 'method' => 'POST', 96 106 'body' => $body, … … 127 137 // Check status of processing task 128 138 function cross_service_solutions_password_protect_pdf_check_status($request) { 129 $nonce = $request->get_header('X-WP-Nonce');130 if (!$nonce || !wp_verify_nonce($nonce, 'password_protect_pdf_form_nonce_action')) {131 return new WP_Error('nonce_invalid', 'Nonce verification failed', array(132 'status' => 403,133 'message' => 'The provided nonce is invalid or expired. Please refresh and try again.'134 ));135 }136 139 137 140 $api_key = esc_attr(get_option('cross_service_solutions_api_key')); 138 141 $id = sanitize_text_field($request['id']); 139 142 140 $response = wp_remote_get("https://api. process-machine-stage.com/solutions/solutions/wordpress/{$id}", array(143 $response = wp_remote_get("https://api.cross-service-solutions.com/solutions/solutions/{$id}", array( 141 144 'headers' => array( 142 145 'Authorization' => 'Bearer ' . $api_key -
password-protect-pdf/tags/1.0.2/includes/verification.php
r3237558 r3311880 17 17 18 18 // API request to verify the API Key 19 $response = wp_remote_get('https://api. process-machine-stage.com/solutions/solutions/wordpress/organization', $args);19 $response = wp_remote_get('https://api.cross-service-solutions.com/solutions/solutions/wordpress/organization', $args); 20 20 21 21 if (is_wp_error($response)) { -
password-protect-pdf/tags/1.0.2/readme.txt
r3260525 r3311880 4 4 Tags: pdf, password, protect pdf, pdf protection 5 5 Requires at least: 5.0 6 Tested up to: 6. 76 Tested up to: 6.8 7 7 Stable tag: 1.0.1 8 8 Requires PHP: 7.2 … … 92 92 == Changelog == 93 93 94 = 1.0.2 = 95 * Updated verify and polling API endpoints 96 94 97 = 1.0.1 = 95 98 * Implemented nonce validation for polling status GET request. -
password-protect-pdf/trunk/includes/process-machine.php
r3260525 r3311880 13 13 'methods' => 'POST', 14 14 'callback' => 'cross_service_solutions_password_protect_pdf_on_submit', 15 'permission_callback' => ' __return_true',15 'permission_callback' => 'cross_service_solutions_password_protect_pdf_verify_nonce', 16 16 )); 17 17 register_rest_route('password-protect-pdf/v1', '/status/(?P<id>\d+)', array( 18 18 'methods' => 'GET', 19 19 'callback' => 'cross_service_solutions_password_protect_pdf_check_status', 20 'permission_callback' => ' __return_true',20 'permission_callback' => 'cross_service_solutions_password_protect_pdf_verify_nonce', 21 21 )); 22 22 } 23 23 add_action('rest_api_init', 'cross_service_solutions_password_protect_pdf_register_rest_api'); 24 25 function cross_service_solutions_password_protect_pdf_verify_nonce($request) { 26 $nonce = $request->get_header('X-WP-Nonce'); 27 28 // If not in header, try body 29 if (!$nonce && isset($request['protectPDFFormNonce'])) { 30 $nonce = sanitize_text_field($request['protectPDFFormNonce']); 31 } 32 33 if (!$nonce || !wp_verify_nonce($nonce, 'password_protect_pdf_form_nonce_action')) { 34 return false; 35 } 36 37 return true; 38 } 24 39 25 40 function cross_service_solutions_test_password_protect_pdf_api_callback() { … … 29 44 // Handle form submission, then initiate processing 30 45 function cross_service_solutions_password_protect_pdf_on_submit($request) { 31 // Check if nonce is set and valid32 if (!isset($request['protectPDFFormNonce']) ||33 !wp_verify_nonce($request['protectPDFFormNonce'], 'password_protect_pdf_form_nonce_action')) {34 return new WP_Error('nonce_invalid', 'Nonce verification failed', array('status' => 403, 'message' => $request['protectPDFFormNonce']));35 }36 46 37 47 $api_key = esc_attr(get_option('cross_service_solutions_api_key')); … … 92 102 93 103 // Make the API request using wp_remote_post 94 $response = wp_remote_post('https://api. process-machine-stage.com/solutions/solutions/wordpress/32', array(104 $response = wp_remote_post('https://api.cross-service-solutions.com/solutions/solutions/wordpress/32', array( 95 105 'method' => 'POST', 96 106 'body' => $body, … … 127 137 // Check status of processing task 128 138 function cross_service_solutions_password_protect_pdf_check_status($request) { 129 $nonce = $request->get_header('X-WP-Nonce');130 if (!$nonce || !wp_verify_nonce($nonce, 'password_protect_pdf_form_nonce_action')) {131 return new WP_Error('nonce_invalid', 'Nonce verification failed', array(132 'status' => 403,133 'message' => 'The provided nonce is invalid or expired. Please refresh and try again.'134 ));135 }136 139 137 140 $api_key = esc_attr(get_option('cross_service_solutions_api_key')); 138 141 $id = sanitize_text_field($request['id']); 139 142 140 $response = wp_remote_get("https://api. process-machine-stage.com/solutions/solutions/wordpress/{$id}", array(143 $response = wp_remote_get("https://api.cross-service-solutions.com/solutions/solutions/{$id}", array( 141 144 'headers' => array( 142 145 'Authorization' => 'Bearer ' . $api_key -
password-protect-pdf/trunk/includes/verification.php
r3237558 r3311880 17 17 18 18 // API request to verify the API Key 19 $response = wp_remote_get('https://api. process-machine-stage.com/solutions/solutions/wordpress/organization', $args);19 $response = wp_remote_get('https://api.cross-service-solutions.com/solutions/solutions/wordpress/organization', $args); 20 20 21 21 if (is_wp_error($response)) { -
password-protect-pdf/trunk/readme.txt
r3260525 r3311880 4 4 Tags: pdf, password, protect pdf, pdf protection 5 5 Requires at least: 5.0 6 Tested up to: 6. 76 Tested up to: 6.8 7 7 Stable tag: 1.0.1 8 8 Requires PHP: 7.2 … … 92 92 == Changelog == 93 93 94 = 1.0.2 = 95 * Updated verify and polling API endpoints 96 94 97 = 1.0.1 = 95 98 * Implemented nonce validation for polling status GET request.
Note: See TracChangeset
for help on using the changeset viewer.