Skip to content

Commit

Permalink
Initial commit; add session id header override
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Fasulo (Work) committed Oct 30, 2023
1 parent 4c69be2 commit 7e94bd2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions options-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ function shibboleth_options_general() {
if ( ! defined( 'SHIBBOLETH_PASSWORD_RESET_URL' ) && isset( $_POST['password_reset_url'] ) ) {
update_site_option( 'shibboleth_password_reset_url', esc_url_raw( wp_unslash( $_POST['password_reset_url'] ) ) );
}
if ( ! defined( 'SHIBBOLETH_SESSION_ID_HEADER' ) && isset( $_POST['session_id_header'] ) ) {
update_site_option( 'shibboleth_session_id_header', sanitize_text_field( wp_unslash( $_POST['session_id_header'] ) ) );
}
if ( ! defined( 'SHIBBOLETH_DEFAULT_TO_SHIB_LOGIN' ) ) {
update_site_option( 'shibboleth_default_to_shib_login', ! empty( $_POST['default_login'] ) );
}
Expand All @@ -149,6 +152,8 @@ function shibboleth_options_general() {
$constant = $constant || $from_constant;
list( $password_reset_url, $from_constant ) = shibboleth_getoption( 'shibboleth_password_reset_url', false, false, true );
$constant = $constant || $from_constant;
list($session_id_header, $from_constant) = shibboleth_getoption('shibboleth_session_id_header', false, false, true);

Check failure on line 155 in options-admin.php

View workflow job for this annotation

GitHub Actions / PHP CodeSniffer

Expected 1 spaces after opening parenthesis; 0 found

Check failure on line 155 in options-admin.php

View workflow job for this annotation

GitHub Actions / PHP CodeSniffer

Expected 1 spaces before closing parenthesis; 0 found
$constant = $constant || $from_constant;
list( $attribute_access, $from_constant ) = shibboleth_getoption( 'shibboleth_attribute_access_method', false, false, true );
$constant = $constant || $from_constant;
list( $attribute_access_fallback, $from_constant ) = shibboleth_getoption( 'shibboleth_attribute_access_method_fallback', false, false, true );
Expand Down Expand Up @@ -224,6 +229,13 @@ function shibboleth_options_general() {
<?php echo wp_kses_post( __( 'If this option is set, wp-login.php will send <b><i>ALL</i></b> users here to reset their password.', 'shibboleth' ) ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="session_id_header"><?php esc_html_e( 'Session ID Header', 'shibboleth' ); ?></label></th>
<td>
<input type="text" id="session_id_header" name="session_id_header" value="<?php echo esc_attr( $session_id_header ); ?>" size="50" <?php defined( 'SHIBBOLETH_SESSION_ID_HEADER' ) && disabled( $session_id_header, SHIBBOLETH_SESSION_ID_HEADER ); ?> /><br />
<?php echo wp_kses_post( __( 'If this option is set, the entered value will override the default Shibboleth header which maps to the Session ID.', 'shibboleth' ) ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="attribute_access"><?php esc_html_e( 'Attribute Access', 'shibboleth' ); ?></label></th>
<td>
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ Yes, the plugin allows for all settings to be controlled via constants in `wp-co
- Format: string
- Available options: none
- Example: `define('SHIBBOLETH_PASSWORD_RESET_URL', 'https://sso.example.com/account/reset');`
- `SHIBBOLETH_SESSION_ID_HEADER`
- Format: string
- Available options: none
- Example: `define('SHIBBOLETH_SESSION_ID_HEADER', 'REDIRECT_MYShib_Shib_Session_ID');`
- `SHIBBOLETH_SPOOF_KEY`
- Format: string
- Available options: none
Expand Down
4 changes: 3 additions & 1 deletion shibboleth.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function shibboleth_activate_plugin() {
add_site_option( 'shibboleth_auto_combine_accounts', 'disallow' );
add_site_option( 'shibboleth_manually_combine_accounts', 'disallow' );
add_site_option( 'shibboleth_disable_local_auth', false );
add_site_option( 'shibboleth_session_id_header', '' );

$headers = array(
'username' => array(
Expand Down Expand Up @@ -376,7 +377,8 @@ function shibboleth_admin_hooks() {
function shibboleth_session_active( $auto_login = false ) {
$active = false;
$method = shibboleth_getoption( 'shibboleth_attribute_access_method' );
$session = shibboleth_getenv( 'Shib-Session-ID' );
$session_id_header = shibboleth_getoption('shibboleth_session_id_header') ? shibboleth_getoption('shibboleth_session_id_header') : 'Shib-Session-ID';

Check failure on line 380 in shibboleth.php

View workflow job for this annotation

GitHub Actions / PHP CodeSniffer

Expected 1 spaces after opening parenthesis; 0 found

Check failure on line 380 in shibboleth.php

View workflow job for this annotation

GitHub Actions / PHP CodeSniffer

Expected 1 spaces before closing parenthesis; 0 found

Check failure on line 380 in shibboleth.php

View workflow job for this annotation

GitHub Actions / PHP CodeSniffer

Expected 1 spaces after opening parenthesis; 0 found

Check failure on line 380 in shibboleth.php

View workflow job for this annotation

GitHub Actions / PHP CodeSniffer

Expected 1 spaces before closing parenthesis; 0 found
$session = shibboleth_getenv( $session_id_header );

if ( $session && 'http' !== $method ) {
$active = true;
Expand Down

0 comments on commit 7e94bd2

Please sign in to comment.