Skip to content
This repository was archived by the owner on Jan 31, 2026. It is now read-only.

Commit e6ce7cb

Browse files
authored
Add auth option (#81)
1 parent 6ef7f5b commit e6ce7cb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ By default, the crawler will respect robots data. You can ignore them though wit
6767
http-status-check scan https://example.com --ignore-robots
6868
```
6969

70+
If your site requires a basic authentification, you can use the `--auth` option:
71+
72+
```bash
73+
http-status-check scan https://example.com --auth=username:password
74+
```
75+
7076
## Testing
7177

7278
To run the tests, first make sure you have [Node.js](https://nodejs.org/) installed. Then start the included node based server in a separate terminal window:

src/ScanCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ protected function configure(): void
6363
InputOption::VALUE_NONE,
6464
'Skips checking the SSL certificate'
6565
)
66+
->addOption(
67+
'auth',
68+
'a',
69+
InputOption::VALUE_OPTIONAL,
70+
'Username and password for basic auth (username:password)'
71+
)
6672
->addOption(
6773
'options',
6874
'opt',
@@ -126,6 +132,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
126132

127133
$clientOptions = array_merge($clientOptions, $input->getOption('options'));
128134

135+
if ($input->getOption('auth') && false !== strpos($input->getOption('auth'), ':')) {
136+
$clientOptions[RequestOptions::AUTH] = explode(':', $input->getOption('auth'));
137+
}
138+
129139
if ($input->getOption('user-agent')) {
130140
$clientOptions[RequestOptions::HEADERS]['user-agent'] = $input->getOption('user-agent');
131141
}

0 commit comments

Comments
 (0)