Merge pull request #189 from dxw/feature/actions-for-error-logging

Increase granularity of state token errors
isekai
Jonathan Daggerhart 5 years ago committed by GitHub
commit d39c0da990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -84,10 +84,15 @@ class OpenID_Connect_Generic_Client {
}
// check the client request state
if ( ! isset( $request['state'] ) || ! $this->check_state( $request['state'] ) ){
if( ! isset( $request['state']) ) {
do_action( 'openid-connect-generic-no-state-provided' );
return new WP_Error( 'missing-state', __( 'Missing state.' ), $request );
}
if ( ! $this->check_state( $request['state'] ) ) {
return new WP_Error( 'invalid-state', __( 'Invalid state.' ), $request );
}
return $request;
}
@ -261,8 +266,20 @@ class OpenID_Connect_Generic_Client {
* @return bool
*/
function check_state( $state ) {
$state_found = true;
if ( ! get_option( '_transient_openid-connect-generic-state--' . $state ) ) {
do_action( 'openid-connect-generic-state-not-found', $state );
$state_found = false;
}
$valid = get_transient( 'openid-connect-generic-state--' . $state );
if ( ! $valid && $state_found ) {
do_action( 'openid-connect-generic-state-expired', $state );
}
return !!$valid;
}

Loading…
Cancel
Save