Skip to content

Commit 4b4b01f

Browse files
committed
Added HTTP auth to /admin
/admin/ -> /admin
1 parent bef9493 commit 4b4b01f

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ Install all required Node.js modules and update GeoIP databases:
1515
Server configuration
1616
--------------------
1717

18-
For server-side you only need to set HTTP server port. You can do it by setting `port` property in `config.json`:
18+
For server-side you only need to set server port and admin credentials.
19+
You can do it by setting `port` property in `config.json`:
1920

2021
```javascript
2122
{
2223
// Chat application server will listen on this port
2324
"port": 1337,
2425

26+
// When you access /admin, HTTP basic authentication will ask to login
27+
"admin": {
28+
"user": "admin",
29+
"password": "admin"
30+
},
31+
2532
// ... other settings which can be managed from chat admin panel
2633
}
2734
```
@@ -86,4 +93,4 @@ If you like to override HTTP port setting, just add `PORT` environment variable
8693
Administration panel
8794
--------------------
8895

89-
Chat admin panel is located at `http://CHAT-APP-HOST:PORT/admin/`.
96+
Chat admin panel is located at `http://CHAT-APP-HOST:PORT/admin`.

app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ app.configure('all', function() {
2121
})
2222

2323
app.use(express.static(path.join(__dirname, 'chat')))
24+
25+
app.use('/admin', express.basicAuth(config.admin.user, config.admin.password))
2426
app.use('/admin', express.static(path.join(__dirname, 'admin')))
2527

2628
/** Router after static */

config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"port": 3000,
3+
"admin": {
4+
"user": "admin",
5+
"password": "admin"
6+
},
37
"allowedDomains": [
48
"127.0.0.1:3000",
59
"127.0.0.1:5000",

models/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ SettingsManager.prototype.serialize = function() {
177177
var out = {}
178178

179179
var keys = [
180-
'port', 'allowedDomains', 'blacklist', 'bannedIPs', 'chatWidth',
180+
'port', 'admin', 'allowedDomains', 'blacklist', 'bannedIPs', 'chatWidth',
181181
'chatHeight', 'allowedURLDomains', 'bitlyLogin', 'bitlyKey',
182182
'coolDownTimeout', 'maxMessagesPerMin', 'savedMessagesCount'
183183
]

routes/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function(app) {
1111
})
1212

1313
// render settings page
14-
app.get('/admin/', function(req, res) {
14+
app.get('/admin', function(req, res) {
1515
res.render('settings')
1616
})
1717
}

0 commit comments

Comments
 (0)