Changeset 3454892
- Timestamp:
- 02/05/2026 07:14:15 PM (7 weeks ago)
- Location:
- daggerhart-openid-connect-generic
- Files:
-
- 16 edited
- 1 copied
-
tags/3.10.3 (copied) (copied from daggerhart-openid-connect-generic/trunk)
-
tags/3.10.3/docker-compose.yml (modified) (1 diff)
-
tags/3.10.3/includes/openid-connect-generic-client-wrapper.php (modified) (9 diffs)
-
tags/3.10.3/includes/openid-connect-generic-client.php (modified) (1 diff)
-
tags/3.10.3/includes/openid-connect-generic-login-form.php (modified) (4 diffs)
-
tags/3.10.3/includes/openid-connect-generic-option-logger.php (modified) (1 diff)
-
tags/3.10.3/languages/openid-connect-generic.pot (modified) (2 diffs)
-
tags/3.10.3/openid-connect-generic.php (modified) (3 diffs)
-
tags/3.10.3/readme.txt (modified) (3 diffs)
-
trunk/docker-compose.yml (modified) (1 diff)
-
trunk/includes/openid-connect-generic-client-wrapper.php (modified) (9 diffs)
-
trunk/includes/openid-connect-generic-client.php (modified) (1 diff)
-
trunk/includes/openid-connect-generic-login-form.php (modified) (4 diffs)
-
trunk/includes/openid-connect-generic-option-logger.php (modified) (1 diff)
-
trunk/languages/openid-connect-generic.pot (modified) (2 diffs)
-
trunk/openid-connect-generic.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
daggerhart-openid-connect-generic/tags/3.10.3/docker-compose.yml
r3067237 r3454892 6 6 services: 7 7 app: 8 image: ghcr.io/ndigitals/wp-dev-container:php-8. 0-node-168 image: ghcr.io/ndigitals/wp-dev-container:php-8.1-node-20 9 9 restart: always 10 10 depends_on: -
daggerhart-openid-connect-generic/tags/3.10.3/includes/openid-connect-generic-client-wrapper.php
r3422318 r3454892 99 99 // Alter the requests according to settings. 100 100 add_filter( 'openid-connect-generic-alter-request', array( $client_wrapper, 'alter_request' ), 10, 2 ); 101 102 // Ensure tokens are refreshed before they expire. 103 if ( $settings->token_refresh_enable ) { 104 add_action( 'init', array( $client_wrapper, 'ensure_tokens_still_fresh' ) ); 105 } 101 106 102 107 if ( is_admin() ) { … … 253 258 254 259 $user_id = wp_get_current_user()->ID; 255 $last_token_response = get_user_meta( $user_id, 'openid-connect-generic-last-token-response', true ); 260 $last_token_response = get_user_option( 'openid-connect-generic-last-token-response', $user_id ); 261 262 if ( false === $last_token_response ) { 263 $last_token_response = get_user_meta( 264 $user_id, 265 'openid-connect-generic-last-token-response', 266 true 267 ); 268 } 256 269 257 270 if ( ! empty( $last_token_response['expires_in'] ) && ! empty( $last_token_response['time'] ) ) { … … 299 312 $token_response[] = time(); 300 313 301 update_user_ meta( $user_id, 'openid-connect-generic-last-token-response', $token_response );314 update_user_option( $user_id, 'openid-connect-generic-last-token-response', $token_response ); 302 315 $this->save_refresh_token( $manager, $token, $token_response ); 303 316 } … … 369 382 } 370 383 371 $token_response = $user->get( 'openid-connect-generic-last-token-response');384 $token_response = get_user_option( 'openid-connect-generic-last-token-response', $user->ID ); 372 385 if ( ! $token_response ) { 373 386 // Happens if non-openid login was used. … … 378 391 } 379 392 380 $claim = $user->get( 'openid-connect-generic-last-id-token-claim');393 $claim = get_user_option( 'openid-connect-generic-last-id-token-claim', $user->ID ); 381 394 382 395 if ( isset( $claim['iss'] ) && 'https://accounts.google.com' == $claim['iss'] ) { … … 641 654 642 655 // Store the tokens for future reference. 643 update_user_ meta( $user->ID, 'openid-connect-generic-last-token-response', $token_response );644 update_user_ meta( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim );645 update_user_ meta( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim );656 update_user_option( $user->ID, 'openid-connect-generic-last-token-response', $token_response ); 657 update_user_option( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim ); 658 update_user_option( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim ); 646 659 647 660 return $user_claim; … … 661 674 public function login_user( $user, $token_response, $id_token_claim, $user_claim, $subject_identity ): void { 662 675 // Store the tokens for future reference. 663 update_user_ meta( $user->ID, 'openid-connect-generic-last-token-response', $token_response );664 update_user_ meta( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim );665 update_user_ meta( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim );676 update_user_option( $user->ID, 'openid-connect-generic-last-token-response', $token_response ); 677 update_user_option( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim ); 678 update_user_option( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim ); 666 679 // Allow plugins / themes to take action using current claims on existing user (e.g. update role). 667 680 do_action( 'openid-connect-generic-update-user-using-current-claim', $user, $user_claim ); … … 1099 1112 1100 1113 // Save some meta data about this new user for the future. 1101 add_user_meta( $user->ID, 'openid-connect-generic-subject-identity', (string) $subject_identity, true );1114 update_user_option( $user->ID, 'openid-connect-generic-subject-identity', (string) $subject_identity, true ); 1102 1115 1103 1116 // Log the results. … … 1121 1134 public function update_existing_user( $uid, $subject_identity ) { 1122 1135 // Add the OpenID Connect meta data. 1123 update_user_ meta( $uid, 'openid-connect-generic-subject-identity', strval( $subject_identity ));1136 update_user_option( $uid, 'openid-connect-generic-subject-identity', strval( $subject_identity ), true ); 1124 1137 1125 1138 // Allow plugins / themes to take action on user update. -
daggerhart-openid-connect-generic/tags/3.10.3/includes/openid-connect-generic-client.php
r3418927 r3454892 343 343 $start_time = microtime( true ); 344 344 $response = wp_remote_get( $this->endpoint_userinfo, $request ); 345 $end_time = microtime( true ); 345 346 // This endpoint can support GET or POST requests according to spec, but some IDPs only allow one. 347 // If the GET request failed to produce valid json, attempt a POST request. 348 // Spec: https://openid.net/specs/openid-connect-core-1_0.html#UserInfoRequest. 349 if ( ! is_wp_error( $response ) && json_decode( $response['body'] ) === null ) { 350 $response = wp_remote_post( $this->endpoint_userinfo, $request ); 351 } 352 353 $end_time = microtime( true ); 346 354 $this->logger->log( $this->endpoint_userinfo, 'request_userinfo', $end_time - $start_time ); 347 355 -
daggerhart-openid-connect-generic/tags/3.10.3/includes/openid-connect-generic-login-form.php
r3067237 r3454892 35 35 36 36 /** 37 * The client object instance. 38 * 39 * @var OpenID_Connect_Generic_Client 40 */ 41 private $client; 42 43 /** 37 44 * The class constructor. 38 45 * 39 46 * @param OpenID_Connect_Generic_Option_Settings $settings A plugin settings object instance. 40 47 * @param OpenID_Connect_Generic_Client_Wrapper $client_wrapper A plugin client wrapper object instance. 41 */ 42 public function __construct( $settings, $client_wrapper ) { 48 * @param OpenID_Connect_Generic_Client $client A plugin client object instance. 49 */ 50 public function __construct( $settings, $client_wrapper, $client ) { 43 51 $this->settings = $settings; 44 52 $this->client_wrapper = $client_wrapper; 53 $this->client = $client; 45 54 } 46 55 … … 50 59 * @param OpenID_Connect_Generic_Option_Settings $settings A plugin settings object instance. 51 60 * @param OpenID_Connect_Generic_Client_Wrapper $client_wrapper A plugin client wrapper object instance. 61 * @param OpenID_Connect_Generic_Client $client A plugin client object instance. 52 62 * 53 63 * @return void 54 64 */ 55 public static function register( $settings, $client_wrapper ) {56 $login_form = new self( $settings, $client_wrapper );65 public static function register( $settings, $client_wrapper, $client ) { 66 $login_form = new self( $settings, $client_wrapper, $client ); 57 67 58 68 // Alter the login form as dictated by settings. … … 140 150 array( 141 151 'button_text' => __( 'Login with OpenID Connect', 'daggerhart-openid-connect-generic' ), 152 'endpoint_login' => $this->settings->endpoint_login, 153 'scope' => $this->settings->scope, 154 'client_id' => $this->settings->client_id, 155 'redirect_uri' => $this->client->get_redirect_uri(), 156 'redirect_to' => $this->client_wrapper->get_redirect_to(), 157 'acr_values' => $this->settings->acr_values, 142 158 ), 143 159 $atts, … … 148 164 $text = esc_html( $text ); 149 165 150 $href = $this->client_wrapper->get_authentication_url( $atts ); 166 $href = $this->client_wrapper->get_authentication_url( 167 array( 168 'endpoint_login' => $atts['endpoint_login'], 169 'scope' => $atts['scope'], 170 'client_id' => $atts['client_id'], 171 'redirect_uri' => $atts['redirect_uri'], 172 'redirect_to' => $atts['redirect_to'], 173 'acr_values' => $atts['acr_values'], 174 ) 175 ); 151 176 $href = esc_url_raw( $href ); 152 177 -
daggerhart-openid-connect-generic/tags/3.10.3/includes/openid-connect-generic-option-logger.php
r3067237 r3454892 175 175 */ 176 176 private function upkeep_logs( $logs ) { 177 $items_to_remove = count( $logs ) - $this->log_limit; 177 $items_to_remove = is_array( $logs ) ? 178 count( $logs ) - $this->log_limit : 179 0; 178 180 179 181 if ( $items_to_remove > 0 ) { -
daggerhart-openid-connect-generic/tags/3.10.3/languages/openid-connect-generic.pot
r3418927 r3454892 5 5 "Project-Id-Version: OpenID Connect Generic 3.10.1\n" 6 6 "Report-Msgid-Bugs-To: " 7 "https://github.com/ daggerhart/openid-connect-generic/issues\n"7 "https://github.com/oidc-wp/openid-connect-generic/issues\n" 8 8 "POT-Creation-Date: 2024-04-09 01:24:09+00:00\n" 9 9 "MIME-Version: 1.0\n" … … 514 514 515 515 #. Plugin URI of the plugin/theme 516 msgid "https://github.com/ daggerhart/openid-connect-generic"516 msgid "https://github.com/oidc-wp/openid-connect-generic" 517 517 msgstr "" 518 518 -
daggerhart-openid-connect-generic/tags/3.10.3/openid-connect-generic.php
r3422318 r3454892 17 17 * Plugin URI: https://github.com/oidc-wp/openid-connect-generic 18 18 * Description: Connect to an OpenID Connect identity provider using Authorization Code Flow. 19 * Version: 3.10. 219 * Version: 3.10.3 20 20 * Requires at least: 5.0 21 21 * Requires PHP: 7.4 … … 94 94 * @var string 95 95 */ 96 const VERSION = '3.10. 2';96 const VERSION = '3.10.3'; 97 97 98 98 /** … … 168 168 } 169 169 170 OpenID_Connect_Generic_Login_Form::register( $this->settings, $this->client_wrapper );170 OpenID_Connect_Generic_Login_Form::register( $this->settings, $this->client_wrapper, $this->client ); 171 171 172 172 // Add a shortcode to get the auth URL. -
daggerhart-openid-connect-generic/tags/3.10.3/readme.txt
r3422318 r3454892 4 4 Requires at least: 5.0 5 5 Tested up to: 6.9.0 6 Stable tag: 3.10. 26 Stable tag: 3.10.3 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 20 20 Much of the documentation can be found on the Settings > OpenID Connect Generic dashboard page. 21 21 22 Please submit issues to the Github repo: https://github.com/ daggerhart/openid-connect-generic22 Please submit issues to the Github repo: https://github.com/oidc-wp/openid-connect-generic 23 23 24 24 == Installation == … … 50 50 51 51 == Changelog == 52 53 = 3.10.3 = 54 55 * Fix issue with log corruption causing fatal error. 56 * Fix: Fallback to a POST request for userinfo when GET fails. 57 * Fix: Improves multisite compatibility by switching to *_user_options() functions. 58 * Fix: Fix for WordPress user session length being very short when refresh tokens are enabled. 52 59 53 60 = 3.10.2 = -
daggerhart-openid-connect-generic/trunk/docker-compose.yml
r3067237 r3454892 6 6 services: 7 7 app: 8 image: ghcr.io/ndigitals/wp-dev-container:php-8. 0-node-168 image: ghcr.io/ndigitals/wp-dev-container:php-8.1-node-20 9 9 restart: always 10 10 depends_on: -
daggerhart-openid-connect-generic/trunk/includes/openid-connect-generic-client-wrapper.php
r3422318 r3454892 99 99 // Alter the requests according to settings. 100 100 add_filter( 'openid-connect-generic-alter-request', array( $client_wrapper, 'alter_request' ), 10, 2 ); 101 102 // Ensure tokens are refreshed before they expire. 103 if ( $settings->token_refresh_enable ) { 104 add_action( 'init', array( $client_wrapper, 'ensure_tokens_still_fresh' ) ); 105 } 101 106 102 107 if ( is_admin() ) { … … 253 258 254 259 $user_id = wp_get_current_user()->ID; 255 $last_token_response = get_user_meta( $user_id, 'openid-connect-generic-last-token-response', true ); 260 $last_token_response = get_user_option( 'openid-connect-generic-last-token-response', $user_id ); 261 262 if ( false === $last_token_response ) { 263 $last_token_response = get_user_meta( 264 $user_id, 265 'openid-connect-generic-last-token-response', 266 true 267 ); 268 } 256 269 257 270 if ( ! empty( $last_token_response['expires_in'] ) && ! empty( $last_token_response['time'] ) ) { … … 299 312 $token_response[] = time(); 300 313 301 update_user_ meta( $user_id, 'openid-connect-generic-last-token-response', $token_response );314 update_user_option( $user_id, 'openid-connect-generic-last-token-response', $token_response ); 302 315 $this->save_refresh_token( $manager, $token, $token_response ); 303 316 } … … 369 382 } 370 383 371 $token_response = $user->get( 'openid-connect-generic-last-token-response');384 $token_response = get_user_option( 'openid-connect-generic-last-token-response', $user->ID ); 372 385 if ( ! $token_response ) { 373 386 // Happens if non-openid login was used. … … 378 391 } 379 392 380 $claim = $user->get( 'openid-connect-generic-last-id-token-claim');393 $claim = get_user_option( 'openid-connect-generic-last-id-token-claim', $user->ID ); 381 394 382 395 if ( isset( $claim['iss'] ) && 'https://accounts.google.com' == $claim['iss'] ) { … … 641 654 642 655 // Store the tokens for future reference. 643 update_user_ meta( $user->ID, 'openid-connect-generic-last-token-response', $token_response );644 update_user_ meta( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim );645 update_user_ meta( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim );656 update_user_option( $user->ID, 'openid-connect-generic-last-token-response', $token_response ); 657 update_user_option( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim ); 658 update_user_option( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim ); 646 659 647 660 return $user_claim; … … 661 674 public function login_user( $user, $token_response, $id_token_claim, $user_claim, $subject_identity ): void { 662 675 // Store the tokens for future reference. 663 update_user_ meta( $user->ID, 'openid-connect-generic-last-token-response', $token_response );664 update_user_ meta( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim );665 update_user_ meta( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim );676 update_user_option( $user->ID, 'openid-connect-generic-last-token-response', $token_response ); 677 update_user_option( $user->ID, 'openid-connect-generic-last-id-token-claim', $id_token_claim ); 678 update_user_option( $user->ID, 'openid-connect-generic-last-user-claim', $user_claim ); 666 679 // Allow plugins / themes to take action using current claims on existing user (e.g. update role). 667 680 do_action( 'openid-connect-generic-update-user-using-current-claim', $user, $user_claim ); … … 1099 1112 1100 1113 // Save some meta data about this new user for the future. 1101 add_user_meta( $user->ID, 'openid-connect-generic-subject-identity', (string) $subject_identity, true );1114 update_user_option( $user->ID, 'openid-connect-generic-subject-identity', (string) $subject_identity, true ); 1102 1115 1103 1116 // Log the results. … … 1121 1134 public function update_existing_user( $uid, $subject_identity ) { 1122 1135 // Add the OpenID Connect meta data. 1123 update_user_ meta( $uid, 'openid-connect-generic-subject-identity', strval( $subject_identity ));1136 update_user_option( $uid, 'openid-connect-generic-subject-identity', strval( $subject_identity ), true ); 1124 1137 1125 1138 // Allow plugins / themes to take action on user update. -
daggerhart-openid-connect-generic/trunk/includes/openid-connect-generic-client.php
r3418927 r3454892 343 343 $start_time = microtime( true ); 344 344 $response = wp_remote_get( $this->endpoint_userinfo, $request ); 345 $end_time = microtime( true ); 345 346 // This endpoint can support GET or POST requests according to spec, but some IDPs only allow one. 347 // If the GET request failed to produce valid json, attempt a POST request. 348 // Spec: https://openid.net/specs/openid-connect-core-1_0.html#UserInfoRequest. 349 if ( ! is_wp_error( $response ) && json_decode( $response['body'] ) === null ) { 350 $response = wp_remote_post( $this->endpoint_userinfo, $request ); 351 } 352 353 $end_time = microtime( true ); 346 354 $this->logger->log( $this->endpoint_userinfo, 'request_userinfo', $end_time - $start_time ); 347 355 -
daggerhart-openid-connect-generic/trunk/includes/openid-connect-generic-login-form.php
r3067237 r3454892 35 35 36 36 /** 37 * The client object instance. 38 * 39 * @var OpenID_Connect_Generic_Client 40 */ 41 private $client; 42 43 /** 37 44 * The class constructor. 38 45 * 39 46 * @param OpenID_Connect_Generic_Option_Settings $settings A plugin settings object instance. 40 47 * @param OpenID_Connect_Generic_Client_Wrapper $client_wrapper A plugin client wrapper object instance. 41 */ 42 public function __construct( $settings, $client_wrapper ) { 48 * @param OpenID_Connect_Generic_Client $client A plugin client object instance. 49 */ 50 public function __construct( $settings, $client_wrapper, $client ) { 43 51 $this->settings = $settings; 44 52 $this->client_wrapper = $client_wrapper; 53 $this->client = $client; 45 54 } 46 55 … … 50 59 * @param OpenID_Connect_Generic_Option_Settings $settings A plugin settings object instance. 51 60 * @param OpenID_Connect_Generic_Client_Wrapper $client_wrapper A plugin client wrapper object instance. 61 * @param OpenID_Connect_Generic_Client $client A plugin client object instance. 52 62 * 53 63 * @return void 54 64 */ 55 public static function register( $settings, $client_wrapper ) {56 $login_form = new self( $settings, $client_wrapper );65 public static function register( $settings, $client_wrapper, $client ) { 66 $login_form = new self( $settings, $client_wrapper, $client ); 57 67 58 68 // Alter the login form as dictated by settings. … … 140 150 array( 141 151 'button_text' => __( 'Login with OpenID Connect', 'daggerhart-openid-connect-generic' ), 152 'endpoint_login' => $this->settings->endpoint_login, 153 'scope' => $this->settings->scope, 154 'client_id' => $this->settings->client_id, 155 'redirect_uri' => $this->client->get_redirect_uri(), 156 'redirect_to' => $this->client_wrapper->get_redirect_to(), 157 'acr_values' => $this->settings->acr_values, 142 158 ), 143 159 $atts, … … 148 164 $text = esc_html( $text ); 149 165 150 $href = $this->client_wrapper->get_authentication_url( $atts ); 166 $href = $this->client_wrapper->get_authentication_url( 167 array( 168 'endpoint_login' => $atts['endpoint_login'], 169 'scope' => $atts['scope'], 170 'client_id' => $atts['client_id'], 171 'redirect_uri' => $atts['redirect_uri'], 172 'redirect_to' => $atts['redirect_to'], 173 'acr_values' => $atts['acr_values'], 174 ) 175 ); 151 176 $href = esc_url_raw( $href ); 152 177 -
daggerhart-openid-connect-generic/trunk/includes/openid-connect-generic-option-logger.php
r3067237 r3454892 175 175 */ 176 176 private function upkeep_logs( $logs ) { 177 $items_to_remove = count( $logs ) - $this->log_limit; 177 $items_to_remove = is_array( $logs ) ? 178 count( $logs ) - $this->log_limit : 179 0; 178 180 179 181 if ( $items_to_remove > 0 ) { -
daggerhart-openid-connect-generic/trunk/languages/openid-connect-generic.pot
r3418927 r3454892 5 5 "Project-Id-Version: OpenID Connect Generic 3.10.1\n" 6 6 "Report-Msgid-Bugs-To: " 7 "https://github.com/ daggerhart/openid-connect-generic/issues\n"7 "https://github.com/oidc-wp/openid-connect-generic/issues\n" 8 8 "POT-Creation-Date: 2024-04-09 01:24:09+00:00\n" 9 9 "MIME-Version: 1.0\n" … … 514 514 515 515 #. Plugin URI of the plugin/theme 516 msgid "https://github.com/ daggerhart/openid-connect-generic"516 msgid "https://github.com/oidc-wp/openid-connect-generic" 517 517 msgstr "" 518 518 -
daggerhart-openid-connect-generic/trunk/openid-connect-generic.php
r3422318 r3454892 17 17 * Plugin URI: https://github.com/oidc-wp/openid-connect-generic 18 18 * Description: Connect to an OpenID Connect identity provider using Authorization Code Flow. 19 * Version: 3.10. 219 * Version: 3.10.3 20 20 * Requires at least: 5.0 21 21 * Requires PHP: 7.4 … … 94 94 * @var string 95 95 */ 96 const VERSION = '3.10. 2';96 const VERSION = '3.10.3'; 97 97 98 98 /** … … 168 168 } 169 169 170 OpenID_Connect_Generic_Login_Form::register( $this->settings, $this->client_wrapper );170 OpenID_Connect_Generic_Login_Form::register( $this->settings, $this->client_wrapper, $this->client ); 171 171 172 172 // Add a shortcode to get the auth URL. -
daggerhart-openid-connect-generic/trunk/readme.txt
r3422318 r3454892 4 4 Requires at least: 5.0 5 5 Tested up to: 6.9.0 6 Stable tag: 3.10. 26 Stable tag: 3.10.3 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 20 20 Much of the documentation can be found on the Settings > OpenID Connect Generic dashboard page. 21 21 22 Please submit issues to the Github repo: https://github.com/ daggerhart/openid-connect-generic22 Please submit issues to the Github repo: https://github.com/oidc-wp/openid-connect-generic 23 23 24 24 == Installation == … … 50 50 51 51 == Changelog == 52 53 = 3.10.3 = 54 55 * Fix issue with log corruption causing fatal error. 56 * Fix: Fallback to a POST request for userinfo when GET fails. 57 * Fix: Improves multisite compatibility by switching to *_user_options() functions. 58 * Fix: Fix for WordPress user session length being very short when refresh tokens are enabled. 52 59 53 60 = 3.10.2 =
Note: See TracChangeset
for help on using the changeset viewer.