-
Notifications
You must be signed in to change notification settings - Fork 3
/
clear-session-template.php
65 lines (50 loc) · 2.18 KB
/
clear-session-template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Template Name: Clear Session Template
*
* Description: Clear cookies and log out of WP and all local IDPs and SPs
*
* @since HCommons
*/
//must set cookies before header
setcookie( 'SimpleSAMLCommons', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), false, true );
setcookie( 'SimpleSAMLAuthToken', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), false, true );
setcookie( '_saml_idp', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), false, true );
setcookie( 'stickyIdPSelection', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), true, true );
setcookie( 'redirect_to', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), true, true );
setcookie( 'wordpress_sec_', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), true, true );
setcookie( 'wordpress_logged_in_', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), true, true );
wp_destroy_current_session();
wp_clear_auth_cookie();
wp_set_current_user( 0 );
$manager = WP_Session_Tokens::get_instance( get_current_user_id() );
$manager->destroy_all();
$shib_urls = [
// IDPs
getenv('GOOGLE_IDP_URL') . '/idp/profile/Logout',
getenv('TWITTER_IDP_URL') . '/idp/profile/Logout',
getenv('MLA_IDP_URL') . '/idp/profile/Logout',
getenv('HC_IDP_URL') . '/idp/profile/Logout',
// SPs
//getenv('REGISTRY_SP_URL') . '/Shibboleth.sso/Logout',
//get_site_url() . '/Shibboleth.sso/Logout',
get_site_url() . '/simplesaml/module.php/core/as_logout.php?AuthId=default-sp',
]; ?>
<?php get_header(); ?>
<?php foreach( $shib_urls as $shib_url ): ?>
<iframe src="<?php echo $shib_url ?>" style="display:none" title="Log Out" ></iframe>
<?php endforeach ?>
<div class="page-full-width">
<div id="primary" class="site-content">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
</article><!-- #post -->
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- .page-full-width -->
<?php get_footer(); ?>