|
5 | 5 | Plugin URI: http://github.com/psignoret/aad-sso-wordpress |
6 | 6 | Description: Allows you to use your organization's Azure Active Directory user accounts to log in to WordPress. If your organization is using Office 365, your user accounts are already in Azure Active Directory. This plugin uses OAuth 2.0 to authenticate users, and the Azure Active Directory Graph to get group membership and other details. |
7 | 7 | Author: Philippe Signoret |
8 | | -Version: 0.6.3 |
| 8 | +Version: 0.6.4 |
9 | 9 | Author URI: https://www.psignoret.com/ |
10 | 10 | Text Domain: aad-sso-wordpress |
11 | 11 | Domain Path: /languages/ |
@@ -83,7 +83,7 @@ public function __construct( $settings ) { |
83 | 83 | add_action( 'login_form', array( $this, 'print_login_link' ) ) ; |
84 | 84 |
|
85 | 85 | // Clear session variables when logging out |
86 | | - add_action( 'wp_logout', array( $this, 'clear_session' ) ); |
| 86 | + add_action( 'wp_logout', array( $this, 'logout' ) ); |
87 | 87 |
|
88 | 88 | // If configured, bypass the login form and redirect straight to AAD |
89 | 89 | add_action( 'login_init', array( $this, 'save_redirect_and_maybe_bypass_login' ), 20 ); |
@@ -348,6 +348,10 @@ function authenticate( $user, $username, $password ) { |
348 | 348 | ); |
349 | 349 | } |
350 | 350 |
|
| 351 | + if ( is_a( $user, 'WP_User' ) ) { |
| 352 | + $_SESSION['aadsso_signed_in_with_azuread'] = true; |
| 353 | + } |
| 354 | + |
351 | 355 | return $user; |
352 | 356 | } |
353 | 357 |
|
@@ -563,6 +567,21 @@ function clear_session() { |
563 | 567 | session_destroy(); |
564 | 568 | } |
565 | 569 |
|
| 570 | + /** |
| 571 | + * Clears the current the session, and triggers a full Azure AD logout if needed. |
| 572 | + */ |
| 573 | + function logout() { |
| 574 | + |
| 575 | + $signed_in_with_azuread = isset( $_SESSION['aadsso_signed_in_with_azuread'] ) |
| 576 | + && true === $_SESSION['aadsso_signed_in_with_azuread']; |
| 577 | + $this->clear_session(); |
| 578 | + |
| 579 | + if ( $signed_in_with_azuread && $this->settings->enable_full_logout ) { |
| 580 | + wp_redirect( $this->get_logout_url() ); |
| 581 | + die(); |
| 582 | + } |
| 583 | + } |
| 584 | + |
566 | 585 | /*** Settings ***/ |
567 | 586 |
|
568 | 587 | /** |
|
0 commit comments