Changeset 2986913
- Timestamp:
- 10/31/2023 04:34:47 PM (2 years ago)
- Location:
- shibboleth
- Files:
-
- 15 added
- 3 edited
-
tags/2.4.3 (added)
-
tags/2.4.3/README.md (added)
-
tags/2.4.3/assets (added)
-
tags/2.4.3/assets/css (added)
-
tags/2.4.3/assets/css/shibboleth_login_form.css (added)
-
tags/2.4.3/assets/js (added)
-
tags/2.4.3/assets/js/shibboleth_login_form.js (added)
-
tags/2.4.3/composer.json (added)
-
tags/2.4.3/icon.png (added)
-
tags/2.4.3/localization (added)
-
tags/2.4.3/localization/shibboleth.pot (added)
-
tags/2.4.3/options-admin.php (added)
-
tags/2.4.3/options-user.php (added)
-
tags/2.4.3/readme.txt (added)
-
tags/2.4.3/shibboleth.php (added)
-
trunk/options-user.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/shibboleth.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shibboleth/trunk/options-user.php
r2958392 r2986913 187 187 check_admin_referer( 'shibboleth-link' ); 188 188 189 $shib_logging = shibboleth_getoption( 'shibboleth_logging', false, true );190 189 $allowed = shibboleth_getoption( 'shibboleth_manually_combine_accounts', 'disallow' ); 191 190 … … 206 205 if ( $user->user_login === $username && strtolower( $user->user_email ) === strtolower( $email ) ) { 207 206 update_user_meta( $user->ID, 'shibboleth_account', true ); 208 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 209 error_log( '[Shibboleth WordPress Plugin Logging] SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts manually.' ); 210 } 207 shibboleth_log_message( 'account_merge', 'SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts manually.' ); 211 208 wp_safe_redirect( get_edit_user_link() . '?shibboleth=linked' ); 212 209 exit; … … 217 214 if ( ! $prevent_conflict->ID ) { 218 215 update_user_meta( $user->ID, 'shibboleth_account', true ); 219 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 220 error_log( '[Shibboleth WordPress Plugin Logging] SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts manually.' ); 221 } 216 shibboleth_log_message( 'account_merge', 'SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts manually.' ); 222 217 wp_safe_redirect( get_edit_user_link() . '?shibboleth=linked' ); 223 218 exit; 224 219 // If username matches and there is an existing account with the email, fail. 225 220 } else { 226 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 227 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: An account already exists with the email: ' . $email . ' .' ); 228 } 221 shibboleth_log_message( 'account_merge', 'ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: An account already exists with the email: ' . $email . ' .' ); 229 222 wp_safe_redirect( get_edit_user_link() . '?shibboleth=failed' ); 230 223 exit; … … 236 229 if ( ! $prevent_conflict->ID ) { 237 230 update_user_meta( $user->ID, 'shibboleth_account', true ); 238 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 239 error_log( '[Shibboleth WordPress Plugin Logging] SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts manually using username bypass. Username provided by attribute is: ' . $username . '.' ); 240 } 231 shibboleth_log_message( 'account_merge', 'SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts manually using username bypass. Username provided by attribute is: ' . $username . '.' ); 241 232 wp_safe_redirect( get_edit_user_link() . '?shibboleth=linked' ); 242 233 exit; 243 234 // If there is an existing account with the email, fail. 244 235 } else { 245 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 246 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts using username bypass. Reason: An account already exists with the email: ' . $email . ' .' ); 247 } 236 shibboleth_log_message( 'account_merge', 'ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts using username bypass. Reason: An account already exists with the email: ' . $email . ' .' ); 248 237 wp_safe_redirect( get_edit_user_link() . '?shibboleth=failed' ); 249 238 exit; … … 251 240 // If no other conditions are met, fail. 252 241 } else { 253 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 254 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: Username and email do not match what is provided by attributes. Username provided by attribute is: ' . $username . ' and email provided by attribute is ' . $email . '.' ); 255 } 242 shibboleth_log_message( 'account_merge', 'ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: Username and email do not match what is provided by attributes. Username provided by attribute is: ' . $username . ' and email provided by attribute is ' . $email . '.' ); 256 243 wp_safe_redirect( get_edit_user_link() . '?shibboleth=failed' ); 257 244 exit; … … 266 253 // If manual merging is disabled, fail. 267 254 } else { 268 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 269 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: Manual account merging is disabled.' ); 270 } 255 shibboleth_log_message( 'account_merge', 'ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: Manual account merging is disabled.' ); 271 256 wp_safe_redirect( get_edit_user_link() . '?shibboleth=failed' ); 272 257 exit; … … 274 259 // If account is already merged, warn. 275 260 } else { 276 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 277 error_log( '[Shibboleth WordPress Plugin Logging] WARN: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: User\'s account is already merged.' ); 278 } 261 shibboleth_log_message( 'account_merge', 'WARN: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to manually merge accounts. Reason: User\'s account is already merged.' ); 279 262 wp_safe_redirect( get_edit_user_link() . '?shibboleth=duplicate' ); 280 263 exit; -
shibboleth/trunk/readme.txt
r2958392 r2986913 1 1 === Shibboleth === 2 Contributors: michaelryanmcneill, willnorris, mitchoyoshitaka, jrchamp, dericcrago, bshelton229, Alhrath, dandalpiaz 2 Contributors: michaelryanmcneill, willnorris, mitchoyoshitaka, jrchamp, dericcrago, bshelton229, Alhrath, dandalpiaz, masteradhoc, junaidkbr 3 3 Tags: shibboleth, authentication, login, saml 4 4 Requires at least: 4.0 5 Tested up to: 6. 35 Tested up to: 6.4 6 6 Requires PHP: 5.6 7 Stable tag: 2.4. 27 Stable tag: 2.4.3 8 8 9 9 Allows WordPress to externalize user authentication and account creation to a Shibboleth Service Provider. … … 198 198 199 199 == Changelog == 200 = version 2.4.3 (not yet released) = 200 = version 2.4.3 (2023-10-31) = 201 - Compatibility: Check for Shibboleth username instead of Shib-Session-ID; thanks @spfncer [#97](https://github.com/michaelryanmcneill/shibboleth/pull/97) 201 202 - CI: Update GitHub Action workflows and code for WordPress coding standard v3 [#94](https://github.com/michaelryanmcneill/shibboleth/pull/94) 203 - Cleanup: Reduced duplication via a logging helper function [#95](https://github.com/michaelryanmcneill/shibboleth/pull/95) 202 204 203 205 = version 2.4.2 (2023-04-07) = -
shibboleth/trunk/shibboleth.php
r2895771 r2986913 9 9 * Plugin URI: https://wordpress.org/plugins/shibboleth/ 10 10 * Description: Easily externalize user authentication to a <a href="https://www.incommon.org/software/shibboleth/">Shibboleth</a> Service Provider 11 * Author: Michael McNeill, mitcho (Michael 芳貴 Erlewine), Will Norris12 * Version: 2.4. 211 * Author: Michael McNeill, Jonathan Champ, Michael Erlewine, Will Norris 12 * Version: 2.4.3 13 13 * Requires PHP: 5.6 14 14 * Requires at least: 4.0 … … 19 19 define( 'SHIBBOLETH_MINIMUM_WP_VERSION', '4.0' ); 20 20 define( 'SHIBBOLETH_MINIMUM_PHP_VERSION', '5.6' ); 21 define( 'SHIBBOLETH_PLUGIN_VERSION', '2.4. 2' );21 define( 'SHIBBOLETH_PLUGIN_VERSION', '2.4.3' ); 22 22 23 23 /** … … 377 377 $active = false; 378 378 $method = shibboleth_getoption( 'shibboleth_attribute_access_method' ); 379 $session = shibboleth_getenv( 'Shib-Session-ID' ); 379 $shib_headers = shibboleth_getoption( 'shibboleth_headers', array(), true ); 380 $session = shibboleth_getenv( $shib_headers['username']['name'] ); 380 381 381 382 if ( $session && 'http' !== $method ) { … … 547 548 } 548 549 550 /** 551 * Log Shibboleth message. 552 * 553 * @param string $message_type Message type. 554 * @param string $message Message. 555 * @since 2.4.3 556 */ 557 function shibboleth_log_message( $message_type, $message ) { 558 static $shib_logging; 559 560 if ( ! isset( $shib_logging ) ) { 561 $shib_logging = shibboleth_getoption( 'shibboleth_logging', array(), true ); 562 } 563 564 if ( defined( 'WP_DEBUG' ) && WP_DEBUG || in_array( $message_type, $shib_logging, true ) ) { 565 error_log( '[Shibboleth WordPress Plugin Logging] ' . $message ); 566 } 567 } 549 568 550 569 /** … … 568 587 function shibboleth_authenticate_user() { 569 588 $shib_headers = shibboleth_getoption( 'shibboleth_headers', array(), true ); 570 $shib_logging = shibboleth_getoption( 'shibboleth_logging', array(), true );571 589 $auto_combine_accounts = shibboleth_getoption( 'shibboleth_auto_combine_accounts' ); 572 590 $manually_combine_accounts = shibboleth_getoption( 'shibboleth_manually_combine_accounts' ); … … 634 652 if ( $do_account_combine ) { 635 653 update_user_meta( $user->ID, 'shibboleth_account', true ); 636 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 637 error_log( '[Shibboleth WordPress Plugin Logging] SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts automatically.' ); 638 } 654 shibboleth_log_message( 'account_merge', 'SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') merged accounts automatically.' ); 639 655 } elseif ( 'username' === $user_by ) { 640 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 641 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to automatically merge accounts. Reason: An account already exists with this username.' ); 642 } 656 shibboleth_log_message( 'account_merge', 'ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to automatically merge accounts. Reason: An account already exists with this username.' ); 643 657 return new WP_Error( 'invalid_username', __( 'An account already exists with this username.', 'shibboleth' ) ); 644 658 } else { 645 if ( in_array( 'account_merge', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 646 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to automatically merge accounts. Reason: An account already exists with this email.' ); 647 } 659 shibboleth_log_message( 'account_merge', 'ERROR: User ' . $user->user_login . ' (ID: ' . $user->ID . ') failed to automatically merge accounts. Reason: An account already exists with this email.' ); 648 660 return new WP_Error( 'invalid_email', __( 'An account already exists with this email.', 'shibboleth' ) ); 649 661 } … … 660 672 if ( ! $user ) { 661 673 $error_message = 'Unable to create account based on data provided.'; 662 if ( in_array( 'account_create', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 663 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: Unable to create account based on data provided.' ); 664 } 674 shibboleth_log_message( 'account_create', 'ERROR: Unable to create account based on data provided.' ); 665 675 return new WP_Error( 'missing_data', $error_message ); 666 676 } … … 674 684 $user_role = shibboleth_get_user_role(); 675 685 $user->set_role( $user_role ); 676 if ( in_array( 'role_update', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 677 error_log( '[Shibboleth WordPress Plugin Logging] SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') role was updated to ' . $user_role . '.' ); 678 } 686 shibboleth_log_message( 'role_update', 'SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') role was updated to ' . $user_role . '.' ); 679 687 do_action( 'shibboleth_set_user_roles', $user ); 680 688 } 681 689 682 if ( in_array( 'auth', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 683 error_log( '[Shibboleth WordPress Plugin Logging] SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') successfully authenticated.' ); 684 } 690 shibboleth_log_message( 'auth', 'SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') successfully authenticated.' ); 685 691 return $user; 686 692 } … … 697 703 function shibboleth_create_new_user( $user_login, $user_email ) { 698 704 $create_accounts = shibboleth_getoption( 'shibboleth_create_accounts' ); 699 $shib_logging = shibboleth_getoption( 'shibboleth_logging', array(), true );700 705 $user_role = shibboleth_get_user_role(); 701 706 … … 714 719 ); 715 720 if ( is_wp_error( $user_id ) ) { 716 if ( in_array( 'account_create', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 717 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: Unable to create account based on data provided. Reason: ' . $user_id->get_error_message() . '.' ); 718 } 721 shibboleth_log_message( 'account_create', 'ERROR: Unable to create account based on data provided. Reason: ' . $user_id->get_error_message() . '.' ); 719 722 return new WP_Error( 'account_create_failed', $user_id->get_error_message() ); 720 723 } else { … … 726 729 $user->set_role( $user_role ); 727 730 do_action( 'shibboleth_set_user_roles', $user ); 728 if ( in_array( 'account_create', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 729 error_log( '[Shibboleth WordPress Plugin Logging] SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') was created with role ' . ( $user_role ? $user_role : 'none' ) . '.' ); 730 } 731 shibboleth_log_message( 'account_create', 'SUCCESS: User ' . $user->user_login . ' (ID: ' . $user->ID . ') was created with role ' . ( $user_role ? $user_role : 'none' ) . '.' ); 731 732 return $user; 732 733 } 733 734 } else { 734 if ( in_array( 'auth', $shib_logging, true ) || defined( 'WP_DEBUG' ) && WP_DEBUG ) { 735 error_log( '[Shibboleth WordPress Plugin Logging] ERROR: User account does not exist and account creation is disabled.' ); 736 } 735 shibboleth_log_message( 'auth', 'ERROR: User account does not exist and account creation is disabled.' ); 737 736 return new WP_Error( 'no_access', __( 'You do not have sufficient access.' ) ); 738 737 }
Note: See TracChangeset
for help on using the changeset viewer.