|
1 | 1 | <?php |
| 2 | +/* |
| 3 | + * includes capabilities for a "remember me" login flag passed as a SAML Attribute. |
| 4 | + * To use, pass a value of 'yes' in a SAML Attribute, then map that attribute |
| 5 | + * name in the WordPress Dashboard SSO Settings here: |
| 6 | + * Wordpress Settings => SSO/SAML Settings => Attribute Mapping => Remember Me |
| 7 | + |
| 8 | + * Other affected files: /php/configuration.php |
| 9 | +*/ |
2 | 10 |
|
3 | 11 | // Make sure we don't expose any info if called directly |
4 | 12 | if ( !function_exists( 'add_action' ) ) { |
@@ -280,10 +288,24 @@ function saml_acs() { |
280 | 288 | exit(); |
281 | 289 | } else if ($user_id) { |
282 | 290 | wp_set_current_user($user_id); |
283 | | - wp_set_auth_cookie($user_id); |
284 | | - setcookie(SAML_LOGIN_COOKIE, 1, time() + YEAR_IN_SECONDS, SITECOOKIEPATH ); |
285 | | - #do_action('wp_login', $user_id); |
286 | | - #wp_signon($user_id); |
| 291 | + |
| 292 | + $remembermeMapping = get_option('onelogin_saml_attr_mapping_rememberme'); |
| 293 | + if ( !empty($remembermeMapping) && isset($attrs[$remembermeMapping]) && !empty($attrs[$remembermeMapping][0])) { |
| 294 | + $rememberme = $attrs[$remembermeMapping][0]; |
| 295 | + } |
| 296 | + |
| 297 | + if ( isset($rememberme) ) { |
| 298 | + // ** Value of 'yes' is assumed to be passed here, if other, need to edit this. |
| 299 | + if ( $rememberme == 'yes' ) { |
| 300 | + wp_set_auth_cookie($user_id, true); |
| 301 | + } else { |
| 302 | + wp_set_auth_cookie($user_id); |
| 303 | + } |
| 304 | + } else { |
| 305 | + wp_set_auth_cookie($user_id); |
| 306 | + } |
| 307 | + |
| 308 | + setcookie('saml_login', 1, time() + YEAR_IN_SECONDS, SITECOOKIEPATH ); |
287 | 309 | } |
288 | 310 |
|
289 | 311 | if (isset($_REQUEST['RelayState'])) { |
|
0 commit comments