Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ with the provided Dockerfile.
|`-P` or `--proxy` |Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com | |
|`--proxy-all` |Forward every request to the proxy target instead of serving local files|`false`|
|`--proxy-options` |Pass proxy [options](https://github.com/http-party/node-http-proxy#options) using nested dotted objects. e.g.: --proxy-options.secure false |
|`--username` |Username for basic authentication | |
|`--user` or `--username` |Username for basic authentication | |
|`--password` |Password for basic authentication | |
|`-S`, `--tls` or `--ssl` |Enable secure request serving with TLS/SSL (HTTPS)|`false`|
|`-C` or `--cert` |Path to ssl cert file |`cert.pem` |
Expand Down
7 changes: 4 additions & 3 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var chalk = require('chalk'),
var argv = require('minimist')(process.argv.slice(2), {
alias: {
tls: 'ssl',
header: 'H'
header: 'H',
user: 'username',
},
boolean: ['proxy-all']
});
Expand Down Expand Up @@ -66,8 +67,8 @@ if (argv.h || argv.help) {
' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false',
' --websocket Enable websocket proxy',
'',
' --username Username for basic authentication [none]',
' Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME',
' --user --username Username for basic authentication [none]',
' Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME',
' --password Password for basic authentication [none]',
' Can also be specified with the env variable NODE_HTTP_SERVER_PASSWORD',
'',
Expand Down
2 changes: 1 addition & 1 deletion doc/http-server.1
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Requires \-\-proxy.
Pass proxy options using nested dotted objects.

.TP
.BI \-\-username " " \fIUSERNAME\fR
.BI \-\-user ", " \-\-username " " \fIUSERNAME\fR
Username for basic authentication.
Can also be specified with the environment variable NODE_HTTP_SERVER_USERNAME.
Defaults to none.
Expand Down
4 changes: 4 additions & 0 deletions lib/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ function HttpServer(options) {
}

if (options.username || options.password) {
if (!options.username || !options.password) {
throw new Error('Basic authentication requires both username and password to be specified');
}

before.push(function (req, res) {
var credentials = auth(req);

Expand Down
Loading