@@ -24,6 +24,7 @@ export class Entry extends Command {
2424 open : flags . boolean ( { char : "o" , description : "Open in browser on startup" } ) ,
2525 port : flags . integer ( { char : "p" , default : 8080 , description : "Port to bind on" } ) ,
2626 version : flags . version ( { char : "v" } ) ,
27+ "no-auth" : flags . boolean ( { default : false } ) ,
2728
2829 // Dev flags
2930 "bootstrap-fork" : flags . string ( { hidden : true } ) ,
@@ -132,41 +133,47 @@ export class Entry extends Command {
132133
133134 const password = "023450wf0951" ;
134135 const hasCustomHttps = certData && certKeyData ;
135- const app = await createApp ( ( app ) => {
136- app . use ( ( req , res , next ) => {
137- res . on ( "finish" , ( ) => {
138- logger . trace ( `\u001B[1m${ req . method } ${ res . statusCode } \u001B[0m${ req . url } ` , field ( "host" , req . hostname ) , field ( "ip" , req . ip ) ) ;
136+ const app = await createApp ( {
137+ bypassAuth : flags [ "no-auth" ] ,
138+ registerMiddleware : ( app ) : void => {
139+ app . use ( ( req , res , next ) => {
140+ res . on ( "finish" , ( ) => {
141+ logger . trace ( `\u001B[1m${ req . method } ${ res . statusCode } \u001B[0m${ req . url } ` , field ( "host" , req . hostname ) , field ( "ip" , req . ip ) ) ;
142+ } ) ;
143+
144+ next ( ) ;
139145 } ) ;
140-
141- next ( ) ;
142- } ) ;
143- // If we're not running from the binary and we aren't serving the static
144- // pre-built version, use webpack to serve the web files.
145- if ( ! isCli && ! serveStatic ) {
146- const webpackConfig = require ( path . join ( __dirname , ".." , ".." , "web" , "webpack.config.js" ) ) ;
147- const compiler = require ( "webpack" ) ( webpackConfig ) ;
148- app . use ( require ( "webpack-dev-middleware" ) ( compiler , {
149- logger,
150- publicPath : webpackConfig . output . publicPath ,
151- stats : webpackConfig . stats ,
152- } ) ) ;
153- app . use ( require ( "webpack-hot-middleware" ) ( compiler ) ) ;
154- }
155- } , {
156- builtInExtensionsDirectory : builtInExtensionsDir ,
157- dataDirectory : dataDir ,
158- workingDirectory : workingDir ,
159- fork : ( modulePath : string , args : string [ ] , options : ForkOptions ) : ChildProcess => {
160- if ( options && options . env && options . env . AMD_ENTRYPOINT ) {
161- return forkModule ( options . env . AMD_ENTRYPOINT , args , options , dataDir ) ;
146+ // If we're not running from the binary and we aren't serving the static
147+ // pre-built version, use webpack to serve the web files.
148+ if ( ! isCli && ! serveStatic ) {
149+ const webpackConfig = require ( path . join ( __dirname , ".." , ".." , "web" , "webpack.config.js" ) ) ;
150+ const compiler = require ( "webpack" ) ( webpackConfig ) ;
151+ app . use ( require ( "webpack-dev-middleware" ) ( compiler , {
152+ logger,
153+ publicPath : webpackConfig . output . publicPath ,
154+ stats : webpackConfig . stats ,
155+ } ) ) ;
156+ app . use ( require ( "webpack-hot-middleware" ) ( compiler ) ) ;
162157 }
163-
164- return fork ( modulePath , args , options ) ;
165158 } ,
166- } , password , hasCustomHttps ? {
167- key : certKeyData ,
168- cert : certData ,
169- } : undefined ) ;
159+ serverOptions : {
160+ builtInExtensionsDirectory : builtInExtensionsDir ,
161+ dataDirectory : dataDir ,
162+ workingDirectory : workingDir ,
163+ fork : ( modulePath : string , args : string [ ] , options : ForkOptions ) : ChildProcess => {
164+ if ( options && options . env && options . env . AMD_ENTRYPOINT ) {
165+ return forkModule ( options . env . AMD_ENTRYPOINT , args , options , dataDir ) ;
166+ }
167+
168+ return fork ( modulePath , args , options ) ;
169+ } ,
170+ } ,
171+ password,
172+ httpsOptions : hasCustomHttps ? {
173+ key : certKeyData ,
174+ cert : certData ,
175+ } : undefined ,
176+ } ) ;
170177
171178 logger . info ( "Starting webserver..." , field ( "host" , flags . host ) , field ( "port" , flags . port ) ) ;
172179 app . server . listen ( flags . port , flags . host ) ;
@@ -191,8 +198,12 @@ export class Entry extends Command {
191198 logger . warn ( "Documentation on securing your setup: https://coder.com/docs" ) ;
192199 }
193200
194- logger . info ( " " ) ;
195- logger . info ( `Password:\u001B[1m ${ password } ` ) ;
201+ if ( ! flags [ "no-auth" ] ) {
202+ logger . info ( " " ) ;
203+ logger . info ( `Password:\u001B[1m ${ password } ` ) ;
204+ } else {
205+ logger . warn ( "Launched without authentication." ) ;
206+ }
196207 logger . info ( " " ) ;
197208 logger . info ( "Started (click the link below to open):" ) ;
198209 logger . info ( `http://localhost:${ flags . port } /` ) ;
0 commit comments