Skip to content

Commit e857c77

Browse files
committed
On multi-site environment, provision users on specific site if JIT enabled on that site.
1 parent 12d6442 commit e857c77

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

onelogin-saml-sso/php/functions.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@ function saml_acs() {
260260
}
261261

262262
if ($user_id) {
263+
if (is_multisite() && !is_user_member_of_blog($user_id, $blog_id)) {
264+
if (get_option('onelogin_saml_autocreate')) {
265+
//Exist's but is not user to the current blog id
266+
$blog_id = get_current_blog_id();
267+
$result = add_user_to_blog($blog_id, $user_id, $userdata['role']);
268+
} else {
269+
$user_id = null;
270+
echo __("User provided by the IdP "). ' "'. esc_attr($matcherValue). '" '. __("does not exist in this wordpress site and auto-provisioning is disabled.");
271+
exit();
272+
}
273+
}
274+
263275
if (get_option('onelogin_saml_updateuser')) {
264276
$userdata['ID'] = $user_id;
265277
unset($userdata['$user_pass']);
@@ -302,8 +314,6 @@ function saml_acs() {
302314
setcookie(SAML_LOGIN_COOKIE, 1, time() + YEAR_IN_SECONDS, SITECOOKIEPATH );
303315
}
304316

305-
do_action( 'onelogin_saml_attrs', $attrs, wp_get_current_user(), get_current_user_id() );
306-
307317
if (isset($_REQUEST['RelayState'])) {
308318
if (!empty($_REQUEST['RelayState']) && ((substr($_REQUEST['RelayState'], -strlen('/wp-login.php')) === '/wp-login.php') || (substr($_REQUEST['RelayState'], -strlen('/alternative_acs.php')) === '/alternative_acs.php'))) {
309319
wp_redirect(home_url());

onelogin-saml-sso/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ To mitigate that bug, place the script at the root of wordpress and execute it (
2828
* Fix bug on escaping value for customize_links_saml_login
2929
* If password is disabled.. turn field readonly.. not disable it
3030
* Add ability to expose attributes that come from saml via a WordPress
31+
* On multi-site environment, provision users on specific site if JIT enabled on that site.
3132

3233
= 2.5.0 =
3334
* Update php-saml library to 2.11.0

0 commit comments

Comments
 (0)