Changeset 3021965
- Timestamp:
- 01/15/2024 03:49:00 PM (7 months ago)
- Location:
- rest-api-guard
- Files:
-
- 336 added
- 2 deleted
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
rest-api-guard/tags/1.1.2/.gitignore
r2801542 r3021965 1 # Build files 2 build 3 vendor 1 .DS_Store 2 Thumbs.db 3 wp-cli.local.yml 4 node_modules/ 5 *.sql 6 *.tar.gz 7 *.zip 8 .phpunit.result.cache 9 Dockerfile 10 output.log 11 tests 12 bin 4 13 composer.lock 5 node_modules 6 7 # Log files 8 *.log 9 10 # Cache files 11 .phpcs/*.json 12 .phpunit.result.cache 13 14 # Ignore temporary OS files 15 .DS_Store 16 .DS_Store? 17 .Spotlight-V100 18 .Trashes 19 ehthumbs.db 20 Thumbs.db 21 .thumbsdb 22 23 # IDE files 24 *.code-workspace 25 .idea 26 .vscode 14 phpcs.xml 15 phpunit.xml 16 configure.php 17 DOCKER_ENV 18 phpunit.xml 19 tests 20 .phpcs 21 Makefile -
rest-api-guard/tags/1.1.2/CHANGELOG.md
r2801542 r3021965 3 3 All notable changes to `wp-rest-guard` will be documented in this file. 4 4 5 ## 0.1.0 - 202X-XX-XX5 ## 6 6 7 - Initial release 7 - Re-releasing to re-trigger the deployment to WordPress.org. 8 9 ## v1.1.0 - 2024-012-12 10 11 - Drops support for PHP 7.4 and requires PHP 8.0. 12 - Add feature to allow anonymous authentication with a JSON Web Token (JWT). 13 14 ## v1.0.4 - 2024-01-12 15 16 - Fixing an issue splitting lines by `\n` instead of `\r\n` on Windows. 17 - Allow `/wp-json/` to be included in the allow/deny lists. 18 19 ## v1.0.3 - 2023-08-28 20 21 - Bumping tested version to 6.3 22 23 ## v1.0.2 - 2022-11-03 24 25 - Fixing another typo in the plugin name. 26 27 ## v1.0.1 - 2022-10-26 28 29 - Fixing a typo on the settings page. 30 31 ## v1.0.0 - 2022-10-19 32 33 - Stable re-release 🎊 -
rest-api-guard/tags/1.1.2/README.md
r2811404 r3021965 1 1 # REST API Guard 2 2 3 Stable tag: 1. 0.23 Stable tag: 1..2 4 4 5 5 Requires at least: 6.0 … … 7 7 Tested up to: 6.0 8 8 9 Requires PHP: 7.49 Requires PHP: 10 10 11 11 License: GPL v2 or later … … 119 119 ``` 120 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 121 167 ## Testing 122 168 -
rest-api-guard/tags/1.1.2/composer.json
r2959576 r3021965 18 18 ], 19 19 "require": { 20 "php": "^7.4|^8.0" 20 "php": "^8.0", 21 "firebase/php-jwt": "^6.10" 21 22 }, 22 23 "require-dev": { 23 "alleyinteractive/alley-coding-standards": "^ 1.0",24 "alleyinteractive/alley-coding-standards": "^.0", 24 25 "alleyinteractive/composer-wordpress-autoloader": "^1.0", 25 26 "mantle-framework/testkit": "^0.7", … … 31 32 "dealerdirect/phpcodesniffer-composer-installer": true, 32 33 "pestphp/pest-plugin": true 34 35 36 33 37 }, 34 38 "sort-packages": true -
rest-api-guard/tags/1.1.2/plugin.php
r2959576 r3021965 4 4 * Plugin URI: https://github.com/alleyinteractive/wp-rest-api-guard 5 5 * Description: Restrict and control access to the REST API 6 * Version: 1. 0.36 * Version: 1. 7 7 * Author: Sean Fisher 8 8 * Author URI: https://alley.co/ … … 18 18 namespace Alley\WP\REST_API_Guard; 19 19 20 21 22 20 23 use WP_Error; 21 24 use WP_REST_Request; … … 30 33 */ 31 34 function main() { 35 36 37 38 32 39 require_once __DIR__ . '/settings.php'; 33 40 … … 41 48 * @param WP_REST_Server $server Server instance. 42 49 * @param WP_REST_Request $request The request object. 43 * @return bool 44 */ 45 function should_prevent_anonymous_access( WP_REST_Server $server, WP_REST_Request $request ): bool { 50 * @return WP_Error|bool 51 * 52 * @throws InvalidArgumentException If the JWT is invalid. 53 */ 54 function should_prevent_anonymous_access( WP_REST_Server $server, WP_REST_Request $request ): WP_Error|bool { 46 55 $settings = (array) get_option( SETTINGS_KEY ); 47 56 48 57 if ( ! is_array( $settings ) ) { 49 58 $settings = []; 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 50 111 } 51 112 … … 93 154 } 94 155 95 // todo: check settings.96 97 156 /** 98 157 * Filter the allowlist for allowed anonymous requests. … … 105 164 if ( ! empty( $allowlist ) ) { 106 165 if ( ! is_array( $allowlist ) ) { 107 $allowlist = explode( "\n", $allowlist );166 $allowlist = , $allowlist ); 108 167 } 109 168 110 169 foreach ( $allowlist as $allowlist_endpoint ) { 170 171 172 173 174 111 175 if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $allowlist_endpoint, '/' ) ) . '/', $endpoint ) ) { 112 176 return false; … … 128 192 if ( ! empty( $denylist ) ) { 129 193 if ( ! is_array( $denylist ) ) { 130 $denylist = explode( "\n", $denylist );194 $denylist = , $denylist ); 131 195 } 132 196 133 197 foreach ( $denylist as $denylist_endpoint ) { 198 199 200 201 202 134 203 if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $denylist_endpoint, '/' ) ) . '/', $endpoint ) ) { 135 204 return true; … … 154 223 } 155 224 156 if ( should_prevent_anonymous_access( $server, $request ) ) { 225 $should_prevent = should_prevent_anonymous_access( $server, $request ); 226 227 if ( is_wp_error( $should_prevent ) ) { 228 return $should_prevent; 229 } elseif ( $should_prevent ) { 157 230 return new WP_Error( 158 231 'rest_api_guard_unauthorized', … … 174 247 return $pre; 175 248 } 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 -
rest-api-guard/tags/1.1.2/readme.txt
r2959576 r3021965 1 1 === REST API Guard === 2 Stable tag: 1. 0.32 Stable tag: 1. 3 3 Requires at least: 6.0 4 4 Tested up to: 6.3 5 Requires PHP: 7.45 Requires PHP: 6 6 License: GPL v2 or later 7 7 Tags: alleyinteractive, rest-api-guard … … 85 85 2 86 86 ); 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 -
rest-api-guard/tags/1.1.2/settings.php
r2805089 r3021965 7 7 8 8 namespace Alley\WP\REST_API_Guard; 9 10 9 11 10 12 if ( ! defined( 'ABSPATH' ) ) { … … 162 164 ], 163 165 ); 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 164 188 } 165 189 … … 233 257 } 234 258 259 260 261 262 263 264 265 235 266 if ( $disabled ) { 236 267 printf( -
rest-api-guard/trunk/.gitignore
r2801542 r3021965 1 # Build files 2 build 3 vendor 1 .DS_Store 2 Thumbs.db 3 wp-cli.local.yml 4 node_modules/ 5 *.sql 6 *.tar.gz 7 *.zip 8 .phpunit.result.cache 9 Dockerfile 10 output.log 11 tests 12 bin 4 13 composer.lock 5 node_modules 6 7 # Log files 8 *.log 9 10 # Cache files 11 .phpcs/*.json 12 .phpunit.result.cache 13 14 # Ignore temporary OS files 15 .DS_Store 16 .DS_Store? 17 .Spotlight-V100 18 .Trashes 19 ehthumbs.db 20 Thumbs.db 21 .thumbsdb 22 23 # IDE files 24 *.code-workspace 25 .idea 26 .vscode 14 phpcs.xml 15 phpunit.xml 16 configure.php 17 DOCKER_ENV 18 phpunit.xml 19 tests 20 .phpcs 21 Makefile -
rest-api-guard/trunk/CHANGELOG.md
r2801542 r3021965 3 3 All notable changes to `wp-rest-guard` will be documented in this file. 4 4 5 ## 0.1.0 - 202X-XX-XX5 ## 6 6 7 - Initial release 7 - Re-releasing to re-trigger the deployment to WordPress.org. 8 9 ## v1.1.0 - 2024-012-12 10 11 - Drops support for PHP 7.4 and requires PHP 8.0. 12 - Add feature to allow anonymous authentication with a JSON Web Token (JWT). 13 14 ## v1.0.4 - 2024-01-12 15 16 - Fixing an issue splitting lines by `\n` instead of `\r\n` on Windows. 17 - Allow `/wp-json/` to be included in the allow/deny lists. 18 19 ## v1.0.3 - 2023-08-28 20 21 - Bumping tested version to 6.3 22 23 ## v1.0.2 - 2022-11-03 24 25 - Fixing another typo in the plugin name. 26 27 ## v1.0.1 - 2022-10-26 28 29 - Fixing a typo on the settings page. 30 31 ## v1.0.0 - 2022-10-19 32 33 - Stable re-release 🎊 -
rest-api-guard/trunk/README.md
r2811404 r3021965 1 1 # REST API Guard 2 2 3 Stable tag: 1. 0.23 Stable tag: 1..2 4 4 5 5 Requires at least: 6.0 … … 7 7 Tested up to: 6.0 8 8 9 Requires PHP: 7.49 Requires PHP: 10 10 11 11 License: GPL v2 or later … … 119 119 ``` 120 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 121 167 ## Testing 122 168 -
rest-api-guard/trunk/composer.json
r2959576 r3021965 18 18 ], 19 19 "require": { 20 "php": "^7.4|^8.0" 20 "php": "^8.0", 21 "firebase/php-jwt": "^6.10" 21 22 }, 22 23 "require-dev": { 23 "alleyinteractive/alley-coding-standards": "^ 1.0",24 "alleyinteractive/alley-coding-standards": "^.0", 24 25 "alleyinteractive/composer-wordpress-autoloader": "^1.0", 25 26 "mantle-framework/testkit": "^0.7", … … 31 32 "dealerdirect/phpcodesniffer-composer-installer": true, 32 33 "pestphp/pest-plugin": true 34 35 36 33 37 }, 34 38 "sort-packages": true -
rest-api-guard/trunk/plugin.php
r2959576 r3021965 4 4 * Plugin URI: https://github.com/alleyinteractive/wp-rest-api-guard 5 5 * Description: Restrict and control access to the REST API 6 * Version: 1. 0.36 * Version: 1. 7 7 * Author: Sean Fisher 8 8 * Author URI: https://alley.co/ … … 18 18 namespace Alley\WP\REST_API_Guard; 19 19 20 21 22 20 23 use WP_Error; 21 24 use WP_REST_Request; … … 30 33 */ 31 34 function main() { 35 36 37 38 32 39 require_once __DIR__ . '/settings.php'; 33 40 … … 41 48 * @param WP_REST_Server $server Server instance. 42 49 * @param WP_REST_Request $request The request object. 43 * @return bool 44 */ 45 function should_prevent_anonymous_access( WP_REST_Server $server, WP_REST_Request $request ): bool { 50 * @return WP_Error|bool 51 * 52 * @throws InvalidArgumentException If the JWT is invalid. 53 */ 54 function should_prevent_anonymous_access( WP_REST_Server $server, WP_REST_Request $request ): WP_Error|bool { 46 55 $settings = (array) get_option( SETTINGS_KEY ); 47 56 48 57 if ( ! is_array( $settings ) ) { 49 58 $settings = []; 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 50 111 } 51 112 … … 93 154 } 94 155 95 // todo: check settings.96 97 156 /** 98 157 * Filter the allowlist for allowed anonymous requests. … … 105 164 if ( ! empty( $allowlist ) ) { 106 165 if ( ! is_array( $allowlist ) ) { 107 $allowlist = explode( "\n", $allowlist );166 $allowlist = , $allowlist ); 108 167 } 109 168 110 169 foreach ( $allowlist as $allowlist_endpoint ) { 170 171 172 173 174 111 175 if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $allowlist_endpoint, '/' ) ) . '/', $endpoint ) ) { 112 176 return false; … … 128 192 if ( ! empty( $denylist ) ) { 129 193 if ( ! is_array( $denylist ) ) { 130 $denylist = explode( "\n", $denylist );194 $denylist = , $denylist ); 131 195 } 132 196 133 197 foreach ( $denylist as $denylist_endpoint ) { 198 199 200 201 202 134 203 if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $denylist_endpoint, '/' ) ) . '/', $endpoint ) ) { 135 204 return true; … … 154 223 } 155 224 156 if ( should_prevent_anonymous_access( $server, $request ) ) { 225 $should_prevent = should_prevent_anonymous_access( $server, $request ); 226 227 if ( is_wp_error( $should_prevent ) ) { 228 return $should_prevent; 229 } elseif ( $should_prevent ) { 157 230 return new WP_Error( 158 231 'rest_api_guard_unauthorized', … … 174 247 return $pre; 175 248 } 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 -
rest-api-guard/trunk/readme.txt
r2959576 r3021965 1 1 === REST API Guard === 2 Stable tag: 1. 0.32 Stable tag: 1. 3 3 Requires at least: 6.0 4 4 Tested up to: 6.3 5 Requires PHP: 7.45 Requires PHP: 6 6 License: GPL v2 or later 7 7 Tags: alleyinteractive, rest-api-guard … … 85 85 2 86 86 ); 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 -
rest-api-guard/trunk/settings.php
r2805089 r3021965 7 7 8 8 namespace Alley\WP\REST_API_Guard; 9 10 9 11 10 12 if ( ! defined( 'ABSPATH' ) ) { … … 162 164 ], 163 165 ); 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 164 188 } 165 189 … … 233 257 } 234 258 259 260 261 262 263 264 265 235 266 if ( $disabled ) { 236 267 printf(
Note: See TracChangeset
for help on using the changeset viewer.