plugins/yubikey/auth.php
changeset 32 b00055a88867
parent 25 2e7ccbdfdc0a
child 33 1303cf9c594c
equal deleted inserted replaced
31:e931602f9f2f 32:b00055a88867
     5 
     5 
     6 // hook into auth
     6 // hook into auth
     7 $plugins->attachHook('login_process_userdata_json', 'return yubikey_auth_hook_json($userinfo, $req["level"], @$req["remember"]);');
     7 $plugins->attachHook('login_process_userdata_json', 'return yubikey_auth_hook_json($userinfo, $req["level"], @$req["remember"]);');
     8 // hook into special page init
     8 // hook into special page init
     9 $plugins->attachHook('session_started', 'yubikey_add_special_pages();');
     9 $plugins->attachHook('session_started', 'yubikey_add_special_pages();');
       
    10 // session key security
       
    11 $plugins->attachHook('session_key_calc', 'yubikey_sk_calc($user_id, $key_pieces, $sk_mode);');
    10 
    12 
    11 function yubikey_auth_hook_json(&$userdata, $level, $remember)
    13 function yubikey_auth_hook_json(&$userdata, $level, $remember)
    12 {
    14 {
    13   global $db, $session, $paths, $template, $plugins; // Common objects
    15   global $db, $session, $paths, $template, $plugins; // Common objects
    14   global $lang;
    16   global $lang;
   238       'namespace' => 'Special',
   240       'namespace' => 'Special',
   239       'visible' => 0, 'protected' => 0, 'comments_on' => 0, 'special' => 0
   241       'visible' => 0, 'protected' => 0, 'comments_on' => 0, 'special' => 0
   240     ));
   242     ));
   241 }
   243 }
   242 
   244 
       
   245 function yubikey_sk_calc($user_id, &$key_pieces, &$sk_mode)
       
   246 {
       
   247   global $db, $session, $paths, $template, $plugins; // Common objects
       
   248   // hash the user's yubikeys
       
   249   $q = $db->sql_query('SELECT yubi_uid FROM ' . table_prefix . "yubikey WHERE user_id = $user_id;");
       
   250   if ( !$q )
       
   251     $db->_die();
       
   252   
       
   253   while ( $row = $db->fetchrow() )
       
   254   {
       
   255     $key_pieces[] = $row['yubi_uid'];
       
   256   }
       
   257 }
       
   258 
   243 function page_Special_Yubikey()
   259 function page_Special_Yubikey()
   244 {
   260 {
   245   global $db, $session, $paths, $template, $plugins; // Common objects
   261   global $db, $session, $paths, $template, $plugins; // Common objects
   246   
   262   
   247   header('Content-type: text/javascript');
   263   header('Content-type: text/javascript');