Skip to content

Commit

Permalink
Merge pull request #74 from dsXLII/feature/filters-munge-shibattrs
Browse files Browse the repository at this point in the history
Add filters to override Shib-provided username and email
  • Loading branch information
jrchamp authored Aug 27, 2021
2 parents f1f644c + d4edb7e commit f706cf0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions shibboleth.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ function shibboleth_session_initiator_url( $redirect = null ) {
* Known users will have their profile data updated based on the Shibboleth
* data present if the plugin is configured to do so.
*
* @uses apply_filters() Calls 'shibboleth_override_username' before authenticating
* @uses apply_filters() Calls 'shibboleth_override_email' before authenticating
*
* @return WP_User|WP_Error authenticated user or error if unable to authenticate
* @since 1.0
*/
Expand All @@ -541,6 +544,31 @@ function shibboleth_authenticate_user() {
$username = shibboleth_getenv( $shib_headers['username']['name'] );
$email = shibboleth_getenv( $shib_headers['email']['name'] );

/**
* Be VERY careful with the below two filters! They can lead to unintended
* consequences, such as multiple Shibboleth users mapping to the same
* WordPress user, or introducing security risks by improperly escaping
* and validating usernames and email addresses.
*/

/**
* Override the username provided by Shibboleth.
*
* This can be used to escape or normalize the Shibboleth username.
*
* @param string $username
*/
$username = apply_filters( 'shibboleth_override_username', $username );

/**
* Override the email address provided by Shibboleth.
*
* This can be used to escape or normalize the Shibboleth email address.
*
* @param string $email
*/
$email = apply_filters( 'shibboleth_override_email', $email );

/**
* Allows a bypass mechanism for native Shibboleth authentication.
*
Expand Down

0 comments on commit f706cf0

Please sign in to comment.