Added setting for http_response_timeout

isekai
Jonathan Daggerhart 10 years ago
parent d0ceb60a37
commit ada93ba4f3

@ -47,6 +47,7 @@ class OpenID_Connect_Generic_Client_Wrapper {
// alter the requests according to settings
add_filter( 'openid-connect-generic-alter-request', array( $client_wrapper, 'alter_request' ), 10, 3 );
add_filter( 'http_request_timeout', array( $client_wrapper, 'alter_http_request_timeout' ) );
if ( is_admin() ) {
// use the ajax url to handle processing authorization without any html output
@ -63,6 +64,21 @@ class OpenID_Connect_Generic_Client_Wrapper {
return $client_wrapper;
}
/**
* WP Hook for altering remote request timeout
*
* @param $timeout
*
* @return int
*/
function alter_http_request_timeout( $timeout ){
if ( is_numeric( $this->settings->http_request_timeout ) ){
return absint( $this->settings->http_request_timeout );
}
return $timeout;
}
/**
* Get the authentication url from the client
*

@ -111,6 +111,10 @@ class OpenID_Connect_Generic_Client {
// call the server and ask for a token
$response = wp_remote_post( $this->endpoint_token, $request );
if ( is_wp_error( $response ) ){
$response->add( 'request_authentication_token' , __( 'Request for authentication token failed.' ) );
}
return $response;
}
@ -147,6 +151,10 @@ class OpenID_Connect_Generic_Client {
// attempt the request
$response = wp_remote_get( $this->endpoint_userinfo . '?access_token=' . $access_token, $request );
if ( is_wp_error( $response ) ){
$response->add( 'request_userinfo' , __( 'Request for userinfo failed.' ) );
}
return $response;
}

@ -85,16 +85,23 @@ class OpenID_Connect_Generic_Settings_Page {
'type' => 'text',
'section' => 'client_settings',
),
'identity_key' => array(
'title' => __( 'Identity Key' ),
'description' => __( 'Where in the user claim array to find the user\'s identification data. Possible standard values: preferred_username, name, or sub. If you\'re having trouble, use "sub".' ),
'example' => 'preferred_username',
'type' => 'text',
'section' => 'client_settings',
),
'no_sslverify' => array(
'title' => __( 'Disable SSL Verify' ),
'description' => __( 'Do not require SSL verification during authorization. The OAuth extension uses curl to make the request. By default CURL will generally verify the SSL certificate to see if its valid an issued by an accepted CA. This setting disabled that verification.' ),
'type' => 'checkbox',
'section' => 'client_settings',
),
'identity_key' => array(
'title' => __( 'Identity Key' ),
'description' => __( 'Where in the user claim array to find the user\'s identification data. Possible standard values: preferred_username, name, or sub. If you\'re having trouble, use "sub".' ),
'example' => 'preferred_username',
'http_request_timeout' => array(
'title' => __( 'HTTP Request Timeout' ),
'description' => __( 'Set the timeout for requests made to the IDP. Default value is 5.' ),
'example' => 5,
'type' => 'text',
'section' => 'client_settings',
),

@ -177,6 +177,7 @@ class OpenID_Connect_Generic {
// non-standard settings
'no_sslverify' => 0,
'http_request_timeout' => 5,
'identity_key' => 'preferred_username',
// plugin settings

Loading…
Cancel
Save