|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|