@@ -5,7 +5,6 @@ import bodyParser from 'body-parser';
5
5
import request from 'request' ;
6
6
import webpack from 'webpack' ;
7
7
import webpackConfig from './webpack.config.js' ;
8
- import basicAuth from 'basic-auth' ;
9
8
10
9
import db , { Controller , pg , User , Tag } from './db' ;
11
10
import Commands from './src/commands' ;
@@ -43,36 +42,8 @@ if (config.env === 'development') {
43
42
app . use ( require ( 'webpack-hot-middleware' ) ( compiler ) ) ;
44
43
}
45
44
46
- function auth ( req , res , next ) {
47
- function unauthorized ( res , user ) {
48
- console . log ( 'WARNING, unauthorized attempt by user:' , user , 'to access route:' , req . originalUrl ) ;
49
- res . set ( 'WWW-Authenticate' , 'Basic' ) ;
50
- return res . sendStatus ( 401 ) ;
51
- }
52
-
53
- var user = basicAuth ( req ) ;
54
-
55
- if ( ! user || ! user . name || ! user . pass ) {
56
- return unauthorized ( res , user ) ;
57
- }
58
-
59
- if ( user . name === config . auth . user && user . pass === config . auth . password ) {
60
- return next ( ) ;
61
- } else {
62
- return unauthorized ( res , user ) ;
63
- }
64
- } ;
65
-
66
- const adminPage = express . static ( path . join ( __dirname , 'client' ) ) ;
67
-
68
- // serve up the admin interface behind auth in production
69
- if ( config . env === 'development' ) {
70
- console . log ( 'WARNING: NO AUTH FOR ADMIN PAGE 🔓' ) ;
71
- app . use ( '/admin' , adminPage ) ;
72
- } else {
73
- console . log ( '🔒 Auth is enabled for admin page access' )
74
- app . use ( '/admin' , [ auth , adminPage ] ) ;
75
- }
45
+ // serve up the admin page
46
+ app . use ( '/admin' , express . static ( path . join ( __dirname , 'client' ) ) ) ;
76
47
77
48
// body parsing
78
49
app . use ( bodyParser . json ( ) ) ;
@@ -296,7 +267,6 @@ app.post('/hook/', function (req, res) {
296
267
res . sendStatus ( status ) ;
297
268
} ) ;
298
269
299
- config . env != 'development' && app . use ( '/messages/' , auth ) ;
300
270
app . post ( '/messages/' , function ( req , res ) {
301
271
if ( ! req . body . message ) {
302
272
return res . sendStatus ( 400 ) ;
@@ -322,7 +292,6 @@ app.post('/messages/', function (req, res) {
322
292
} ) ;
323
293
} ) ;
324
294
325
- config . env != 'development' && app . use ( '/send/' , auth ) ;
326
295
app . post ( '/send/' , function ( req , res ) {
327
296
if ( ! req . body . messageId ) {
328
297
return res . status ( 400 ) . json ( { message : '`messageId` must be specified in request' } ) ;
@@ -351,7 +320,6 @@ app.post('/send/', function (req, res) {
351
320
} ) ;
352
321
} ) ;
353
322
354
- config . env != 'development' && app . use ( '/triggers/' , auth ) ;
355
323
app . post ( '/triggers/' , function ( req , res ) {
356
324
357
325
const triggerTagId = req . body . triggerTagId ,
@@ -397,17 +365,6 @@ app.post('/triggers/', function (req, res) {
397
365
const server = require ( 'http' ) . Server ( app ) ;
398
366
const io = require ( 'socket.io' ) ( server ) ;
399
367
400
- // auth for websockets
401
- if ( config . env != 'development' ) {
402
- io . use ( ( socket , next ) => {
403
- var user = basicAuth ( socket . request ) ;
404
- if ( ! user || user . name !== config . auth . user || user . pass !== config . auth . password ) {
405
- return console . log ( 'WARNING, unauthorized websocket connection attempt:' , user ) ;
406
- }
407
- next && next ( ) ;
408
- } ) ;
409
- }
410
-
411
368
io . on ( 'connection' , function ( socket ) {
412
369
socket . on ( 'get-responses' , ( options ) => {
413
370
Controller . getResponses ( {
0 commit comments