diff options
| author | Piotr Pawlow <pp@siedziba.pl> | 2017-03-19 20:25:12 +0100 |
|---|---|---|
| committer | Piotr Pawlow <pp@siedziba.pl> | 2017-03-19 20:25:12 +0100 |
| commit | 9f91ec73d50bc1b9c0b5a9e7bad0dd84a184a5fc (patch) | |
| tree | 18b328cf2504163a80de52a4c730234c5df5beea | |
| parent | 1ce93f9391411f2b4197b8d4f1f7a24d5804b845 (diff) | |
Allow overwriting config options with arguments.
| -rw-r--r-- | auth.php | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -14,11 +14,19 @@ $lockfile = fopen(__FILE__, 'r'); if ($lockfile === FALSE) die("Cannot open lock file\n"); if (!flock($lockfile, LOCK_EX)) die("Cannot acquire exclisive lock\n"); -$options = getopt("c:"); +$options = getopt("c:", [ + 'secret:', + 'period:', + 'window:', + 'digest:', + 'digits:', + 'delay:' +]); if (isset($options['c'])) $config = load_config($options['c']); else $config = new stdClass(); $config_default = load_config(__DIR__.'/config_default.json'); foreach($config_default as $k => $v) if (!isset($config->{$k})) $config->{$k} = $v; +foreach($options as $k => $v) if ($k !== 'c') $config->{$k} = $v; if (!preg_match('/^[A-Z2-7]+$/i', $config->secret)) die("Base32 encoded secret required\n"); $totp = new TOTP(null, $config->secret, $config->period, $config->digest, $config->digits); |
