plugins/yubikey/admincp.php
author Dan
Fri, 18 Dec 2009 19:28:57 -0500
changeset 34 6e947fa21237
parent 27 647f0aa485dd
child 37 5e946a3f405b
permissions -rw-r--r--
Auth lib/hook fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     1
<?php
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     2
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     3
$plugins->attachHook('acp_general_users', 'yubikey_admin_cp_ui();');
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     4
$plugins->attachHook('acp_general_save', 'yubikey_admin_cp_save();');
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     5
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     6
function yubikey_admin_cp_ui()
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     7
{
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     8
  global $lang;
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
     9
  ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    10
    <tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    11
      <th colspan="2" class="subhead">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    12
        <?php echo $lang->get('yubiacp_th'); ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    13
      </th>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    14
    </tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    15
    
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    16
    <tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    17
      <td class="row1">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    18
        <?php echo $lang->get('yubiacp_field_enable_title'); ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    19
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    20
      <td class="row1">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    21
        <label>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    22
          <input type="checkbox" name="yubikey_enable" <?php if ( getConfig('yubikey_enable', '1') == '1' ) echo 'checked="checked" '; ?>/>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    23
          <?php echo $lang->get('yubiacp_field_enable'); ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    24
        </label>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    25
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    26
    </tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    27
    
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    28
    <tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    29
      <td class="row2">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    30
        <?php echo $lang->get('yubiacp_field_api_key'); ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    31
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    32
      <td class="row2">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    33
        <input type="text" name="yubikey_api_key" value="<?php echo htmlspecialchars(getConfig('yubikey_api_key', '')); ?>" size="30" />
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    34
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    35
    </tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    36
    
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    37
    <tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    38
      <td class="row1">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    39
        <?php echo $lang->get('yubiacp_field_api_key_id'); ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    40
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    41
      <td class="row1">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    42
        <input type="text" name="yubikey_api_key_id" value="<?php echo strval(intval(getConfig('yubikey_api_key_id', ''))); ?>" size="5" />
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    43
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    44
    </tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    45
    
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    46
    <tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    47
      <td class="row2">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    48
        <?php echo $lang->get('yubiacp_field_auth_server'); ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    49
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    50
      <td class="row2">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    51
        <input type="text" name="yubikey_auth_server" value="<?php echo htmlspecialchars(getConfig('yubikey_auth_server', YK_DEFAULT_VERIFY_URL)); ?>" size="30" />
27
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    52
        <?php
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    53
        if ( defined('YMS_INSTALLED') )
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    54
        {
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    55
          echo '<br />';
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    56
          echo $lang->get('yubiacp_field_use_local_pre');
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    57
          ?> <label><input type="checkbox" name="yubikey_use_local_yms" <?php echo getConfig('yubikey_use_local_yms', 0) ? 'checked="checked" ' : ''; ?>/><?php
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    58
          echo $lang->get('yubiacp_field_use_local');
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    59
          echo '</label>';
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    60
        }
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
    61
        ?>
0
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    62
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    63
    </tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    64
    
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    65
    <tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    66
      <td class="row1">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    67
        <?php echo $lang->get('yubiacp_field_enroll_limit'); ?>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    68
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    69
      <td class="row1">
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    70
        <input type="text" name="yubikey_enroll_limit" value="<?php echo strval(intval(getConfig('yubikey_enroll_limit', '3'))); ?>" size="5" />
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    71
      </td>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    72
    </tr>
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    73
    
8
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    74
    <tr>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    75
      <td class="row2">
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    76
        <?php echo $lang->get('yubiacp_field_reg_require_otp_title'); ?><br />
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    77
        <small><?php echo $lang->get('yubiacp_field_reg_require_otp_hint'); ?></small>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    78
      </td>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    79
      <td class="row2">
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    80
        <label>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    81
          <input type="checkbox" name="yubikey_reg_require_otp" <?php if ( getConfig('yubikey_reg_require_otp', '0') == '1' ) echo 'checked="checked" '; ?>/>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    82
          <?php echo $lang->get('yubiacp_field_reg_require_otp'); ?>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    83
        </label>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    84
      </td>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    85
    </tr>
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    86
    
0
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    87
  <?php
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    88
}
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    89
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    90
function yubikey_admin_cp_save()
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    91
{
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    92
  global $lang;
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    93
  
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    94
  // yubikey_enable, yubikey_api_key, yubikey_api_key_id, yubikey_auth_server, yubikey_enroll_limit
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    95
  setConfig('yubikey_enable', isset($_POST['yubikey_enable']) ? '1' : '0');
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    96
  setConfig('yubikey_api_key', $_POST['yubikey_api_key']);
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    97
  setConfig('yubikey_api_key_id', intval($_POST['yubikey_api_key_id']));
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
    98
  setConfig('yubikey_enroll_limit', intval($_POST['yubikey_enroll_limit']));
8
032ca892b9a2 Added option to enroll Yubikey during registration + option in admin CP to require enrollment
Dan
parents: 0
diff changeset
    99
  setConfig('yubikey_reg_require_otp', isset($_POST['yubikey_reg_require_otp']) ? '1' : '0');
27
647f0aa485dd Some modifications to support the YMS plugin
Dan
parents: 8
diff changeset
   100
  setConfig('yubikey_use_local_yms', isset($_POST['yubikey_use_local_yms']) && defined('YMS_INSTALLED') ? '1' : '0');
0
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
   101
  
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
   102
  if ( preg_match('#^(?:https?://)?(\[?[a-z0-9-:]+(?:\.[a-z0-9-:]+\]?)*)(/.*)$#', $_POST['yubikey_auth_server']) )
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
   103
    setConfig('yubikey_auth_server', $_POST['yubikey_auth_server']);
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
   104
  else
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
   105
    echo '<div class="error-box">' . $lang->get('yubiacp_err_invalid_auth_server') . '</div>';
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
   106
}
9d2c4f04a0d0 First commit! Hoping everything works.
Dan
parents:
diff changeset
   107