Plugin Directory

Changeset 3218440


Ignore:
Timestamp:
01/07/2025 04:00:33 PM (14 months ago)
Author:
ashfame
Message:

Update to version 2.0.0 from GitHub

Location:
openid-connect-server
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • openid-connect-server/tags/2.0.0/README.md

    r3107953 r3218440  
    77- Requires PHP: 7.4
    88- License: [GPLv2](http://www.gnu.org/licenses/gpl-2.0.html)
    9 - Stable tag: 1.3.4
     9- Stable tag: 2.0.0
    1010- GitHub Plugin URI: https://github.com/Automattic/wp-openid-connect-server
    1111
     
    7676## Changelog
    7777
     78### 2.0.0
     79
     80- [Breaking] Add a configuration option to support clients that don't require consent [#118](https://github.com/Automattic/wp-openid-connect-server/pull/118) props @lart2150
     81- Make client_id and client_secret optional for the token endpoint [#116](https://github.com/Automattic/wp-openid-connect-server/pull/116) props @lart2150
     82- Update expected args specs for token endpoint as per OIDC spec [#117](https://github.com/Automattic/wp-openid-connect-server/pull/117)
     83
    7884### 1.3.4
     85
    7986- Add the autoloader to the uninstall script [#111](https://github.com/Automattic/wp-openid-connect-server/pull/111) props @MariaMozgunova
    8087
  • openid-connect-server/tags/2.0.0/openid-connect-server.php

    r3107953 r3218440  
    44 * Plugin URI:        https://github.com/Automattic/wp-openid-connect-server
    55 * Description:       Use OpenID Connect to log in to other webservices using your own WordPress.
    6  * Version:           1.3.4
     6 * Version:           2.0.0
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
  • openid-connect-server/tags/2.0.0/src/Http/Handlers/AuthenticateHandler.php

    r2919178 r3218440  
    77use OpenIDConnectServer\Http\RequestHandler;
    88use OpenIDConnectServer\Http\Router;
     9use OpenIDConnectServer\Storage\ClientCredentialsStorage;
    910use OpenIDConnectServer\Storage\ConsentStorage;
    1011
    1112class AuthenticateHandler extends RequestHandler {
    1213    private ConsentStorage $consent_storage;
    13     private array $clients;
     14    private ClientCredentialsStorage $clients;
    1415
    15     public function __construct( ConsentStorage $consent_storage, array $clients ) {
     16    public function __construct( ConsentStorage $consent_storage, ClientCredentialsStorage $clients ) {
    1617        $this->consent_storage = $consent_storage;
    1718        $this->clients         = $clients;
     
    2324        }
    2425
    25         $client_name = $this->get_client_name( $request );
     26        $client_id = $request->query( 'client_id' );
     27
     28        $client_name = $this->clients->getClientName( $client_id );
    2629        if ( empty( $client_name ) ) {
    2730            $response->setStatusCode( 404 );
     
    3033        }
    3134
    32         $client_id = $request->query( 'client_id' );
    33         if ( ! $this->consent_storage->needs_consent( get_current_user_id(), $client_id ) ) {
     35        if (
     36        ! $this->clients->clientRequiresConsent( $client_id )
     37        || ! $this->consent_storage->needs_consent( get_current_user_id(), $client_id )
     38        ) {
    3439            $this->redirect( $request );
    3540            // TODO: return response instead of exiting.
     
    156161    }
    157162
    158     /**
    159      * TODO: Remove this function in favour of ClientCredentialsStorage?
    160      */
    161     private function get_client_name( Request $request ): string {
    162         $client_id = $request->query( 'client_id' );
    163 
    164         if ( ! isset( $this->clients[ $client_id ] ) ) {
    165             return '';
    166         }
    167 
    168         $client = $this->clients[ $client_id ];
    169 
    170         if ( empty( $client['name'] ) ) {
    171             return '';
    172         }
    173 
    174         return $client['name'];
    175     }
    176 
    177163    private function get_cancel_url( Request $request ) {
    178164        return add_query_arg(
  • openid-connect-server/tags/2.0.0/src/Http/Handlers/AuthorizeHandler.php

    r3007179 r3218440  
    99use OAuth2\Server as OAuth2Server;
    1010use OpenIDConnectServer\Http\RequestHandler;
     11use OpenIDConnectServer\Storage\ClientCredentialsStorage;
    1112use OpenIDConnectServer\Storage\ConsentStorage;
    1213
     
    1617    private OAuth2Server $server;
    1718    private ConsentStorage $consent_storage;
     19    private ClientCredentialsStorage $clients;
    1820
    19     public function __construct( OAuth2Server $server, ConsentStorage $consent_storage ) {
     21    public function __construct( OAuth2Server $server, ConsentStorage $consent_storage, ClientCredentialsStorage $clients ) {
    2022        $this->server          = $server;
    2123        $this->consent_storage = $consent_storage;
     24        $this->clients         = $clients;
    2225    }
    2326
     
    4548
    4649        $client_id = $request->query( 'client_id', $request->request( 'client_id' ) );
    47         if ( $this->consent_storage->needs_consent( $user->ID, $client_id ) ) {
     50        if (
     51            $this->clients->clientRequiresConsent( $client_id )
     52            && $this->consent_storage->needs_consent( $user->ID, $client_id )
     53        ) {
    4854            if ( ! isset( $_POST['authorize'] ) || __( 'Authorize', 'openid-connect-server' ) !== $_POST['authorize'] ) {
    4955                $response->setError( 403, 'user_authorization_required', 'This application requires your consent.' );
  • openid-connect-server/tags/2.0.0/src/OpenIDConnectServer.php

    r2910089 r3218440  
    2121class OpenIDConnectServer {
    2222    private string $public_key;
    23     private array $clients;
     23    private ClientCredentialsStorage $clients;
    2424    private Router $router;
    2525    private ConsentStorage $consent_storage;
     
    2727    public function __construct( string $public_key, string $private_key, array $clients ) {
    2828        $this->public_key      = $public_key;
    29         $this->clients         = $clients;
     29        $this->clients         = new ClientCredentialsStorage( $clients );
    3030        $this->router          = new Router();
    3131        $this->consent_storage = new ConsentStorage();
     
    3939        $server = new Server( new AuthorizationCodeStorage(), $config );
    4040        $server->addStorage( new PublicKeyStorage( $public_key, $private_key ), 'public_key' );
    41         $server->addStorage( new ClientCredentialsStorage( $clients ), 'client_credentials' );
     41        $server->addStorage( $this->clients, 'client_credentials' );
    4242        $server->addStorage( new UserClaimsStorage(), 'user_claims' );
    4343
     
    5151        $this->router->add_rest_route(
    5252            'authorize',
    53             new AuthorizeHandler( $server, $this->consent_storage ),
     53            new AuthorizeHandler( $server, $this->consent_storage, $this->clients ),
    5454            array( 'GET', 'POST' ),
    5555            $this->expected_arguments_specification( 'authorize' ),
     
    101101            case 'token':
    102102                return array(
    103                     'grant_type'    => array(
     103                    'grant_type'            => array(
    104104                        'type'     => 'string',
    105105                        'required' => true,
    106106                    ),
    107                     'client_id'     => array(
     107                    'client_id'             => array(
     108                        'type'     => 'string',
     109                        'required' => false,
     110                    ),
     111                    'client_secret'         => array(
     112                        'type'     => 'string',
     113                        'required' => false,
     114                    ),
     115                    'client_assertion'      => array(
     116                        'type'     => 'string',
     117                        'required' => false,
     118                    ),
     119                    'client_assertion_type' => array(
     120                        'type'     => 'string',
     121                        'required' => false,
     122                    ),
     123                    'redirect_uri'          => array(
    108124                        'type'     => 'string',
    109125                        'required' => true,
    110126                    ),
    111                     'client_secret' => array(
    112                         'type'     => 'string',
    113                         'required' => true,
    114                     ),
    115                     'redirect_uri'  => array(
    116                         'type'     => 'string',
    117                         'required' => true,
    118                     ),
    119                     'code'          => array(
     127                    'code'                  => array(
    120128                        'type'     => 'string',
    121129                        'required' => true,
  • openid-connect-server/tags/2.0.0/src/Storage/ClientCredentialsStorage.php

    r2807756 r3218440  
    2424            'scope'        => $client['scope'],
    2525        );
     26    }
     27
     28    public function getClientName( $client_id ) {
     29        if ( ! $this->has( $client_id ) ) {
     30            return '';
     31        }
     32
     33        $client = $this->get( $client_id );
     34
     35        if ( empty( $client['name'] ) ) {
     36            return '';
     37        }
     38
     39        return $client['name'];
     40    }
     41
     42    public function clientRequiresConsent( $client_id ): bool {
     43        if ( ! $this->has( $client_id ) ) {
     44            return true;
     45        }
     46
     47        $client = $this->get( $client_id );
     48
     49        if ( ! array_key_exists( 'requires_consent', $client ) ) {
     50            return true;
     51        }
     52
     53        return false !== $client['requires_consent'];
    2654    }
    2755
  • openid-connect-server/tags/2.0.0/vendor/composer/InstalledVersions.php

    r2894121 r3218440  
    323323
    324324        $installed = array();
     325        $copiedLocalDir = false;
    325326
    326327        if (self::$canGetVendors) {
     
    331332                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    332333                    $required = require $vendorDir.'/composer/installed.php';
    333                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    334                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    335                         self::$installed = $installed[count($installed) - 1];
     334                    self::$installedByVendor[$vendorDir] = $required;
     335                    $installed[] = $required;
     336                    if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
     337                        self::$installed = $required;
     338                        $copiedLocalDir = true;
    336339                    }
    337340                }
     
    351354        }
    352355
    353         if (self::$installed !== array()) {
     356        if (self::$installed !== array() && !$copiedLocalDir) {
    354357            $installed[] = self::$installed;
    355358        }
  • openid-connect-server/tags/2.0.0/vendor/composer/installed.php

    r3107953 r3218440  
    22    'root' => array(
    33        'name' => '__root__',
    4         'pretty_version' => '1.3.4',
    5         'version' => '1.3.4.0',
     4        'pretty_version' => '2.0.0',
     5        'version' => '2.0.0.0',
    66        'reference' => null,
    77        'type' => 'library',
     
    1212    'versions' => array(
    1313        '__root__' => array(
    14             'pretty_version' => '1.3.4',
    15             'version' => '1.3.4.0',
     14            'pretty_version' => '2.0.0',
     15            'version' => '2.0.0.0',
    1616            'reference' => null,
    1717            'type' => 'library',
  • openid-connect-server/trunk/README.md

    r3107953 r3218440  
    77- Requires PHP: 7.4
    88- License: [GPLv2](http://www.gnu.org/licenses/gpl-2.0.html)
    9 - Stable tag: 1.3.4
     9- Stable tag: 2.0.0
    1010- GitHub Plugin URI: https://github.com/Automattic/wp-openid-connect-server
    1111
     
    7676## Changelog
    7777
     78### 2.0.0
     79
     80- [Breaking] Add a configuration option to support clients that don't require consent [#118](https://github.com/Automattic/wp-openid-connect-server/pull/118) props @lart2150
     81- Make client_id and client_secret optional for the token endpoint [#116](https://github.com/Automattic/wp-openid-connect-server/pull/116) props @lart2150
     82- Update expected args specs for token endpoint as per OIDC spec [#117](https://github.com/Automattic/wp-openid-connect-server/pull/117)
     83
    7884### 1.3.4
     85
    7986- Add the autoloader to the uninstall script [#111](https://github.com/Automattic/wp-openid-connect-server/pull/111) props @MariaMozgunova
    8087
  • openid-connect-server/trunk/openid-connect-server.php

    r3107953 r3218440  
    44 * Plugin URI:        https://github.com/Automattic/wp-openid-connect-server
    55 * Description:       Use OpenID Connect to log in to other webservices using your own WordPress.
    6  * Version:           1.3.4
     6 * Version:           2.0.0
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
  • openid-connect-server/trunk/src/Http/Handlers/AuthenticateHandler.php

    r2919178 r3218440  
    77use OpenIDConnectServer\Http\RequestHandler;
    88use OpenIDConnectServer\Http\Router;
     9use OpenIDConnectServer\Storage\ClientCredentialsStorage;
    910use OpenIDConnectServer\Storage\ConsentStorage;
    1011
    1112class AuthenticateHandler extends RequestHandler {
    1213    private ConsentStorage $consent_storage;
    13     private array $clients;
     14    private ClientCredentialsStorage $clients;
    1415
    15     public function __construct( ConsentStorage $consent_storage, array $clients ) {
     16    public function __construct( ConsentStorage $consent_storage, ClientCredentialsStorage $clients ) {
    1617        $this->consent_storage = $consent_storage;
    1718        $this->clients         = $clients;
     
    2324        }
    2425
    25         $client_name = $this->get_client_name( $request );
     26        $client_id = $request->query( 'client_id' );
     27
     28        $client_name = $this->clients->getClientName( $client_id );
    2629        if ( empty( $client_name ) ) {
    2730            $response->setStatusCode( 404 );
     
    3033        }
    3134
    32         $client_id = $request->query( 'client_id' );
    33         if ( ! $this->consent_storage->needs_consent( get_current_user_id(), $client_id ) ) {
     35        if (
     36        ! $this->clients->clientRequiresConsent( $client_id )
     37        || ! $this->consent_storage->needs_consent( get_current_user_id(), $client_id )
     38        ) {
    3439            $this->redirect( $request );
    3540            // TODO: return response instead of exiting.
     
    156161    }
    157162
    158     /**
    159      * TODO: Remove this function in favour of ClientCredentialsStorage?
    160      */
    161     private function get_client_name( Request $request ): string {
    162         $client_id = $request->query( 'client_id' );
    163 
    164         if ( ! isset( $this->clients[ $client_id ] ) ) {
    165             return '';
    166         }
    167 
    168         $client = $this->clients[ $client_id ];
    169 
    170         if ( empty( $client['name'] ) ) {
    171             return '';
    172         }
    173 
    174         return $client['name'];
    175     }
    176 
    177163    private function get_cancel_url( Request $request ) {
    178164        return add_query_arg(
  • openid-connect-server/trunk/src/Http/Handlers/AuthorizeHandler.php

    r3007179 r3218440  
    99use OAuth2\Server as OAuth2Server;
    1010use OpenIDConnectServer\Http\RequestHandler;
     11use OpenIDConnectServer\Storage\ClientCredentialsStorage;
    1112use OpenIDConnectServer\Storage\ConsentStorage;
    1213
     
    1617    private OAuth2Server $server;
    1718    private ConsentStorage $consent_storage;
     19    private ClientCredentialsStorage $clients;
    1820
    19     public function __construct( OAuth2Server $server, ConsentStorage $consent_storage ) {
     21    public function __construct( OAuth2Server $server, ConsentStorage $consent_storage, ClientCredentialsStorage $clients ) {
    2022        $this->server          = $server;
    2123        $this->consent_storage = $consent_storage;
     24        $this->clients         = $clients;
    2225    }
    2326
     
    4548
    4649        $client_id = $request->query( 'client_id', $request->request( 'client_id' ) );
    47         if ( $this->consent_storage->needs_consent( $user->ID, $client_id ) ) {
     50        if (
     51            $this->clients->clientRequiresConsent( $client_id )
     52            && $this->consent_storage->needs_consent( $user->ID, $client_id )
     53        ) {
    4854            if ( ! isset( $_POST['authorize'] ) || __( 'Authorize', 'openid-connect-server' ) !== $_POST['authorize'] ) {
    4955                $response->setError( 403, 'user_authorization_required', 'This application requires your consent.' );
  • openid-connect-server/trunk/src/OpenIDConnectServer.php

    r2910089 r3218440  
    2121class OpenIDConnectServer {
    2222    private string $public_key;
    23     private array $clients;
     23    private ClientCredentialsStorage $clients;
    2424    private Router $router;
    2525    private ConsentStorage $consent_storage;
     
    2727    public function __construct( string $public_key, string $private_key, array $clients ) {
    2828        $this->public_key      = $public_key;
    29         $this->clients         = $clients;
     29        $this->clients         = new ClientCredentialsStorage( $clients );
    3030        $this->router          = new Router();
    3131        $this->consent_storage = new ConsentStorage();
     
    3939        $server = new Server( new AuthorizationCodeStorage(), $config );
    4040        $server->addStorage( new PublicKeyStorage( $public_key, $private_key ), 'public_key' );
    41         $server->addStorage( new ClientCredentialsStorage( $clients ), 'client_credentials' );
     41        $server->addStorage( $this->clients, 'client_credentials' );
    4242        $server->addStorage( new UserClaimsStorage(), 'user_claims' );
    4343
     
    5151        $this->router->add_rest_route(
    5252            'authorize',
    53             new AuthorizeHandler( $server, $this->consent_storage ),
     53            new AuthorizeHandler( $server, $this->consent_storage, $this->clients ),
    5454            array( 'GET', 'POST' ),
    5555            $this->expected_arguments_specification( 'authorize' ),
     
    101101            case 'token':
    102102                return array(
    103                     'grant_type'    => array(
     103                    'grant_type'            => array(
    104104                        'type'     => 'string',
    105105                        'required' => true,
    106106                    ),
    107                     'client_id'     => array(
     107                    'client_id'             => array(
     108                        'type'     => 'string',
     109                        'required' => false,
     110                    ),
     111                    'client_secret'         => array(
     112                        'type'     => 'string',
     113                        'required' => false,
     114                    ),
     115                    'client_assertion'      => array(
     116                        'type'     => 'string',
     117                        'required' => false,
     118                    ),
     119                    'client_assertion_type' => array(
     120                        'type'     => 'string',
     121                        'required' => false,
     122                    ),
     123                    'redirect_uri'          => array(
    108124                        'type'     => 'string',
    109125                        'required' => true,
    110126                    ),
    111                     'client_secret' => array(
    112                         'type'     => 'string',
    113                         'required' => true,
    114                     ),
    115                     'redirect_uri'  => array(
    116                         'type'     => 'string',
    117                         'required' => true,
    118                     ),
    119                     'code'          => array(
     127                    'code'                  => array(
    120128                        'type'     => 'string',
    121129                        'required' => true,
  • openid-connect-server/trunk/src/Storage/ClientCredentialsStorage.php

    r2807756 r3218440  
    2424            'scope'        => $client['scope'],
    2525        );
     26    }
     27
     28    public function getClientName( $client_id ) {
     29        if ( ! $this->has( $client_id ) ) {
     30            return '';
     31        }
     32
     33        $client = $this->get( $client_id );
     34
     35        if ( empty( $client['name'] ) ) {
     36            return '';
     37        }
     38
     39        return $client['name'];
     40    }
     41
     42    public function clientRequiresConsent( $client_id ): bool {
     43        if ( ! $this->has( $client_id ) ) {
     44            return true;
     45        }
     46
     47        $client = $this->get( $client_id );
     48
     49        if ( ! array_key_exists( 'requires_consent', $client ) ) {
     50            return true;
     51        }
     52
     53        return false !== $client['requires_consent'];
    2654    }
    2755
  • openid-connect-server/trunk/vendor/composer/InstalledVersions.php

    r2894121 r3218440  
    323323
    324324        $installed = array();
     325        $copiedLocalDir = false;
    325326
    326327        if (self::$canGetVendors) {
     
    331332                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    332333                    $required = require $vendorDir.'/composer/installed.php';
    333                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    334                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    335                         self::$installed = $installed[count($installed) - 1];
     334                    self::$installedByVendor[$vendorDir] = $required;
     335                    $installed[] = $required;
     336                    if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
     337                        self::$installed = $required;
     338                        $copiedLocalDir = true;
    336339                    }
    337340                }
     
    351354        }
    352355
    353         if (self::$installed !== array()) {
     356        if (self::$installed !== array() && !$copiedLocalDir) {
    354357            $installed[] = self::$installed;
    355358        }
  • openid-connect-server/trunk/vendor/composer/installed.php

    r3107953 r3218440  
    22    'root' => array(
    33        'name' => '__root__',
    4         'pretty_version' => '1.3.4',
    5         'version' => '1.3.4.0',
     4        'pretty_version' => '2.0.0',
     5        'version' => '2.0.0.0',
    66        'reference' => null,
    77        'type' => 'library',
     
    1212    'versions' => array(
    1313        '__root__' => array(
    14             'pretty_version' => '1.3.4',
    15             'version' => '1.3.4.0',
     14            'pretty_version' => '2.0.0',
     15            'version' => '2.0.0.0',
    1616            'reference' => null,
    1717            'type' => 'library',
Note: See TracChangeset for help on using the changeset viewer.