Plugin Directory

Changeset 3021965

Timestamp:
01/15/2024 03:49:00 PM (7 months ago)
Author:
sean212
Message:

Update to version 1.1.2 from GitHub

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
     2Thumbs.db
     3wp-cli.local.yml
     4node_modules/
     5*.sql
     6*.tar.gz
     7*.zip
     8.phpunit.result.cache
     9Dockerfile
     10output.log
     11tests
     12bin
    413composer.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
     14phpcs.xml
     15phpunit.xml
     16configure.php
     17DOCKER_ENV
     18phpunit.xml
     19tests
     20.phpcs
     21Makefile
  • rest-api-guard/tags/1.1.2/CHANGELOG.md

    r2801542 r3021965  
    33All notable changes to `wp-rest-guard` will be documented in this file.
    44
    5 ## 0.1.0 - 202X-XX-XX
     5##
    66
    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  
    11# REST API Guard
    22
    3 Stable tag: 1.0.2
     3Stable tag: 1..2
    44
    55Requires at least: 6.0
     
    77Tested up to: 6.0
    88
    9 Requires PHP: 7.4
     9Requires PHP:
    1010
    1111License: GPL v2 or later
     
    119119```
    120120
     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
    121167## Testing
    122168
  • rest-api-guard/tags/1.1.2/composer.json

    r2959576 r3021965  
    1818    ],
    1919    "require": {
    20         "php": "^7.4|^8.0"
     20        "php": "^8.0",
     21        "firebase/php-jwt": "^6.10"
    2122    },
    2223    "require-dev": {
    23         "alleyinteractive/alley-coding-standards": "^1.0",
     24        "alleyinteractive/alley-coding-standards": "^.0",
    2425        "alleyinteractive/composer-wordpress-autoloader": "^1.0",
    2526        "mantle-framework/testkit": "^0.7",
     
    3132            "dealerdirect/phpcodesniffer-composer-installer": true,
    3233            "pestphp/pest-plugin": true
     34
     35
     36
    3337        },
    3438        "sort-packages": true
  • rest-api-guard/tags/1.1.2/plugin.php

    r2959576 r3021965  
    44 * Plugin URI: https://github.com/alleyinteractive/wp-rest-api-guard
    55 * Description: Restrict and control access to the REST API
    6  * Version: 1.0.3
     6 * Version: 1.
    77 * Author: Sean Fisher
    88 * Author URI: https://alley.co/
     
    1818namespace Alley\WP\REST_API_Guard;
    1919
     20
     21
     22
    2023use WP_Error;
    2124use WP_REST_Request;
     
    3033 */
    3134function main() {
     35
     36
     37
     38
    3239    require_once __DIR__ . '/settings.php';
    3340
     
    4148 * @param WP_REST_Server  $server  Server instance.
    4249 * @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 */
     54function should_prevent_anonymous_access( WP_REST_Server $server, WP_REST_Request $request ): WP_Error|bool {
    4655    $settings = (array) get_option( SETTINGS_KEY );
    4756
    4857    if ( ! is_array( $settings ) ) {
    4958        $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
    50111    }
    51112
     
    93154    }
    94155
    95     // todo: check settings.
    96 
    97156    /**
    98157     * Filter the allowlist for allowed anonymous requests.
     
    105164    if ( ! empty( $allowlist ) ) {
    106165        if ( ! is_array( $allowlist ) ) {
    107             $allowlist = explode( "\n", $allowlist );
     166            $allowlist = , $allowlist );
    108167        }
    109168
    110169        foreach ( $allowlist as $allowlist_endpoint ) {
     170
     171
     172
     173
     174
    111175            if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $allowlist_endpoint, '/' ) ) . '/', $endpoint ) ) {
    112176                return false;
     
    128192    if ( ! empty( $denylist ) ) {
    129193        if ( ! is_array( $denylist ) ) {
    130             $denylist = explode( "\n", $denylist );
     194            $denylist = , $denylist );
    131195        }
    132196
    133197        foreach ( $denylist as $denylist_endpoint ) {
     198
     199
     200
     201
     202
    134203            if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $denylist_endpoint, '/' ) ) . '/', $endpoint ) ) {
    135204                return true;
     
    154223    }
    155224
    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 ) {
    157230        return new WP_Error(
    158231            'rest_api_guard_unauthorized',
     
    174247    return $pre;
    175248}
     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  
    11=== REST API Guard ===
    2 Stable tag: 1.0.3
     2Stable tag: 1.
    33Requires at least: 6.0
    44Tested up to: 6.3
    5 Requires PHP: 7.4
     5Requires PHP:
    66License: GPL v2 or later
    77Tags: alleyinteractive, rest-api-guard
     
    8585        2
    8686    );
     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  
    77
    88namespace Alley\WP\REST_API_Guard;
     9
     10
    911
    1012if ( ! defined( 'ABSPATH' ) ) {
     
    162164        ],
    163165    );
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
    164188}
    165189
     
    233257    }
    234258
     259
     260
     261
     262
     263
     264
     265
    235266    if ( $disabled ) {
    236267        printf(
  • rest-api-guard/trunk/.gitignore

    r2801542 r3021965  
    1 # Build files
    2 build
    3 vendor
     1.DS_Store
     2Thumbs.db
     3wp-cli.local.yml
     4node_modules/
     5*.sql
     6*.tar.gz
     7*.zip
     8.phpunit.result.cache
     9Dockerfile
     10output.log
     11tests
     12bin
    413composer.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
     14phpcs.xml
     15phpunit.xml
     16configure.php
     17DOCKER_ENV
     18phpunit.xml
     19tests
     20.phpcs
     21Makefile
  • rest-api-guard/trunk/CHANGELOG.md

    r2801542 r3021965  
    33All notable changes to `wp-rest-guard` will be documented in this file.
    44
    5 ## 0.1.0 - 202X-XX-XX
     5##
    66
    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  
    11# REST API Guard
    22
    3 Stable tag: 1.0.2
     3Stable tag: 1..2
    44
    55Requires at least: 6.0
     
    77Tested up to: 6.0
    88
    9 Requires PHP: 7.4
     9Requires PHP:
    1010
    1111License: GPL v2 or later
     
    119119```
    120120
     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
    121167## Testing
    122168
  • rest-api-guard/trunk/composer.json

    r2959576 r3021965  
    1818    ],
    1919    "require": {
    20         "php": "^7.4|^8.0"
     20        "php": "^8.0",
     21        "firebase/php-jwt": "^6.10"
    2122    },
    2223    "require-dev": {
    23         "alleyinteractive/alley-coding-standards": "^1.0",
     24        "alleyinteractive/alley-coding-standards": "^.0",
    2425        "alleyinteractive/composer-wordpress-autoloader": "^1.0",
    2526        "mantle-framework/testkit": "^0.7",
     
    3132            "dealerdirect/phpcodesniffer-composer-installer": true,
    3233            "pestphp/pest-plugin": true
     34
     35
     36
    3337        },
    3438        "sort-packages": true
  • rest-api-guard/trunk/plugin.php

    r2959576 r3021965  
    44 * Plugin URI: https://github.com/alleyinteractive/wp-rest-api-guard
    55 * Description: Restrict and control access to the REST API
    6  * Version: 1.0.3
     6 * Version: 1.
    77 * Author: Sean Fisher
    88 * Author URI: https://alley.co/
     
    1818namespace Alley\WP\REST_API_Guard;
    1919
     20
     21
     22
    2023use WP_Error;
    2124use WP_REST_Request;
     
    3033 */
    3134function main() {
     35
     36
     37
     38
    3239    require_once __DIR__ . '/settings.php';
    3340
     
    4148 * @param WP_REST_Server  $server  Server instance.
    4249 * @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 */
     54function should_prevent_anonymous_access( WP_REST_Server $server, WP_REST_Request $request ): WP_Error|bool {
    4655    $settings = (array) get_option( SETTINGS_KEY );
    4756
    4857    if ( ! is_array( $settings ) ) {
    4958        $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
    50111    }
    51112
     
    93154    }
    94155
    95     // todo: check settings.
    96 
    97156    /**
    98157     * Filter the allowlist for allowed anonymous requests.
     
    105164    if ( ! empty( $allowlist ) ) {
    106165        if ( ! is_array( $allowlist ) ) {
    107             $allowlist = explode( "\n", $allowlist );
     166            $allowlist = , $allowlist );
    108167        }
    109168
    110169        foreach ( $allowlist as $allowlist_endpoint ) {
     170
     171
     172
     173
     174
    111175            if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $allowlist_endpoint, '/' ) ) . '/', $endpoint ) ) {
    112176                return false;
     
    128192    if ( ! empty( $denylist ) ) {
    129193        if ( ! is_array( $denylist ) ) {
    130             $denylist = explode( "\n", $denylist );
     194            $denylist = , $denylist );
    131195        }
    132196
    133197        foreach ( $denylist as $denylist_endpoint ) {
     198
     199
     200
     201
     202
    134203            if ( preg_match( '/' . str_replace( '\*', '.*', preg_quote( $denylist_endpoint, '/' ) ) . '/', $endpoint ) ) {
    135204                return true;
     
    154223    }
    155224
    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 ) {
    157230        return new WP_Error(
    158231            'rest_api_guard_unauthorized',
     
    174247    return $pre;
    175248}
     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  
    11=== REST API Guard ===
    2 Stable tag: 1.0.3
     2Stable tag: 1.
    33Requires at least: 6.0
    44Tested up to: 6.3
    5 Requires PHP: 7.4
     5Requires PHP:
    66License: GPL v2 or later
    77Tags: alleyinteractive, rest-api-guard
     
    8585        2
    8686    );
     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  
    77
    88namespace Alley\WP\REST_API_Guard;
     9
     10
    911
    1012if ( ! defined( 'ABSPATH' ) ) {
     
    162164        ],
    163165    );
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
    164188}
    165189
     
    233257    }
    234258
     259
     260
     261
     262
     263
     264
     265
    235266    if ( $disabled ) {
    236267        printf(
Note: See TracChangeset for help on using the changeset viewer.