diff --git a/openid_provider.module b/openid_provider.module index 8fe42ec..25d4ee4 100644 --- a/openid_provider.module +++ b/openid_provider.module @@ -185,6 +185,29 @@ function openid_provider_admin_settings() { '#description' => t('This will enable debugging of this module to the watchdog.'), '#default_value' => variable_get('openid_provider_debugging', false), ); + $form['sitelist'] = array( + '#type' => 'fieldset', + '#title' => t('Sites management'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + $form['sitelist']['openid_provider_whitelist'] = array( + '#type' => 'textarea', + '#title' => t('Whitelist'), + '#default_value' => variable_get('openid_provider_whitelist', ""), + '#description' => t('Site on this list will be automatic login using OpenID from this site without confirmation page. Please fill in full site name e.g. http://www.example.com/'), + ); + $form['sitelist']['openid_provider_whitelist_only'] = array( + '#type' => 'checkbox', + '#title' => t('Disable anonymouse site'), + '#default_value' => variable_get('openid_provider_whitelist_only', FALSE), + '#description' => t('Only allow site on whitelist to login using OpenID from this site.'), + ); + $form['sitelist']['openid_provider_blacklist'] = array( + '#type' => 'textarea', + '#title' => t('Blacklist'), + '#default_value' => variable_get('openid_provider_blacklist', ""), + ); return system_settings_form($form); } @@ -243,6 +266,19 @@ function openid_provider_form(&$form_state, $response = array(), $realm = NULL) $realm = $form_state['storage']['realm']; } + $whitelist = explode("\r\n", variable_get('openid_provider_whitelist', "")); + $blacklist = explode("\r\n", variable_get('openid_provider_blacklist', "")); + $whitelist_only = variable_get('openid_provider_whitelist_only', FALSE); + + // If realm on whitelist, by pass the confirm page and continue login. + // If realm on blacklist, or whitelist_only, cancle the login request. + if (in_array($realm, $whitelist)) { + openid_provider_form_submit_always($form, $form_state); + } + elseif (in_array($realm, $blacklist) or $whitelist_only) { + openid_provider_form_submit_cancel($form, $form_state); + } + $form = array(); // Force FAPI to cache this form so that $form_state['storage'] is available