KerberosAuthentication.php
changeset 1 8b637ff5e977
parent 0 5a5a654fae1a
equal deleted inserted replaced
0:5a5a654fae1a 1:8b637ff5e977
   157       );
   157       );
   158   }
   158   }
   159 }
   159 }
   160 
   160 
   161 // Registration blocking hook
   161 // Registration blocking hook
   162 if ( getConfig('kerb_disable_local_auth', 0) == 1 )
   162 if ( getConfig('kerb_disable_local_auth', 0) == 1 && getConfig('kerb_enable', 0) == 1 )
   163 {
   163 {
   164   $plugins->attachHook('ucp_register_validate', 'kerb_auth_reg_block($error);');
   164   $plugins->attachHook('ucp_register_validate', 'kerb_auth_reg_block($error);');
   165 }
   165 }
   166 
   166 
   167 function kerb_auth_reg_block(&$error)
   167 function kerb_auth_reg_block(&$error)
   173 // ADMIN
   173 // ADMIN
   174 //
   174 //
   175 
   175 
   176 $plugins->attachHook('session_started', 'kerb_session_hook();');
   176 $plugins->attachHook('session_started', 'kerb_session_hook();');
   177 
   177 
   178 if ( getConfig('kerb_disable_local_auth', 0) == 1 )
   178 if ( getConfig('kerb_disable_local_auth', 0) == 1 && getConfig('kerb_enable', 0) == 1 )
   179 {
   179 {
   180   $plugins->attachHook('common_post', 'kerb_tou_hook();');
   180   $plugins->attachHook('common_post', 'kerb_tou_hook();');
   181 }
   181 }
   182 
   182 
   183 function kerb_session_hook()
   183 function kerb_session_hook()
   186   
   186   
   187   // Register the admin page
   187   // Register the admin page
   188   $paths->addAdminNode('adm_cat_security', 'Kerberos Authentication', 'KerberosConfig');
   188   $paths->addAdminNode('adm_cat_security', 'Kerberos Authentication', 'KerberosConfig');
   189   
   189   
   190   // Disable password change
   190   // Disable password change
   191   if ( getConfig('kerb_disable_local_auth', 0) == 1 && $session->user_level < USER_LEVEL_ADMIN )
   191   if ( getConfig('kerb_disable_local_auth', 0) == 1 && getConfig('kerb_enable', 0) == 1 && $session->user_level < USER_LEVEL_ADMIN )
   192   {
   192   {
   193     $link_text = getConfig('kerb_password_text', false);
   193     $link_text = getConfig('kerb_password_text', false);
   194     if ( empty($link_text) )
   194     if ( empty($link_text) )
   195       $link_text = false;
   195       $link_text = false;
   196     $link_url = str_replace('%u', $session->username, getConfig('kerb_password_url', ''));
   196     $link_url = str_replace('%u', $session->username, getConfig('kerb_password_url', ''));
   274   if ( $session->auth_level < USER_LEVEL_ADMIN )
   274   if ( $session->auth_level < USER_LEVEL_ADMIN )
   275     return false;
   275     return false;
   276 
   276 
   277   require_once(ENANO_ROOT . '/plugins/kerbauth/libkrb5.php');
   277   require_once(ENANO_ROOT . '/plugins/kerbauth/libkrb5.php');
   278   
   278   
       
   279   $can_enable = function_exists('kadm5_init_with_password');
       
   280   
   279   if ( isset($_POST['submit']) )
   281   if ( isset($_POST['submit']) )
   280   {
   282   {
   281     setConfig('kerb_enable', isset($_POST['kerb_enable']) ? '1' : '0');
   283     setConfig('kerb_enable', isset($_POST['kerb_enable']) && $can_enable ? '1' : '0');
   282     setConfig('kerb_realm', $_POST['kerb_realm']);
   284     setConfig('kerb_realm', $_POST['kerb_realm']);
   283     setConfig('kerb_admin_server', $_POST['kerb_admin_server']);
   285     setConfig('kerb_admin_server', $_POST['kerb_admin_server']);
   284     setConfig('kerb_disable_local_auth', isset($_POST['kerb_disable_local_auth']) ? '1' : '0');
   286     setConfig('kerb_disable_local_auth', isset($_POST['kerb_disable_local_auth']) ? '1' : '0');
   285     setConfig('kerb_password_text', $_POST['kerb_password_text']);
   287     setConfig('kerb_password_text', $_POST['kerb_password_text']);
   286     setConfig('kerb_password_url', $_POST['kerb_password_url']);
   288     setConfig('kerb_password_url', $_POST['kerb_password_url']);
   302       <!-- Kerberos enable -->
   304       <!-- Kerberos enable -->
   303       
   305       
   304       <tr>
   306       <tr>
   305         <td class="row2" style="width: 50%;">
   307         <td class="row2" style="width: 50%;">
   306           Enable Kerberos authentication:
   308           Enable Kerberos authentication:
       
   309           <?php
       
   310           if ( !$can_enable )
       
   311           	  echo '<br /><small>Please install the kadm5 PHP extension to enable Kerberos authentication.</small>';
       
   312           ?>
   307         </td>
   313         </td>
   308         <td class="row1" style="width: 50%;">
   314         <td class="row1" style="width: 50%;">
   309           <label>
   315           <label>
   310             <input type="checkbox" name="kerb_enable" <?php if ( getConfig('kerb_enable', 0) ) echo 'checked="checked" '; ?>/>
   316             <input type="checkbox" name="kerb_enable" <?php if ( getConfig('kerb_enable', 0) && $can_enable ) echo 'checked="checked" '; if ( !$can_enable ) echo 'disabled="disabled" '; ?>/>
   311             Enabled
   317             Enabled
   312           </label>
   318           </label>
   313         </td>
   319         </td>
   314       </tr>
   320       </tr>
   315       
   321