@@ -40,7 +40,10 @@ const COS_SECRET_ACCESS_KEY = process.env.cos_secret_access_key;
4040const APPID_OAUTH_SERVER_URL = process . env . appid_oauth_server_url ;
4141const APPID_CLIENT_ID = process . env . appid_client_id ;
4242const APPID_SECRET = process . env . appid_secret ;
43- const APPID_REDIRECT_URIS = process . env . appid_redirect_uris . split ( ',' ) ; ;
43+ const APPID_REDIRECT_URIS = process . env . appid_redirect_uris . split ( ',' ) ;
44+ const DEBUG_FLAG = process . env . LOCAL_DEBUG ;
45+
46+ console . log ( DEBUG_FLAG ) ;
4447
4548// Express setup, including session and passport support
4649var app = express ( ) ;
@@ -141,15 +144,15 @@ app.use(configureOIDC);
141144// default protected route /authtest
142145app . get ( '/authtest' , ( req , res , next ) => {
143146 passport . authenticate ( 'oidc' , {
144- redirect_uri : req . secure ? 'https ' : 'http' + `://${ req . headers . host } /redirect_uri` ,
147+ redirect_uri : ` ${ DEBUG_FLAG ? 'http ' : 'https' } ` + `://${ req . headers . host } /redirect_uri` ,
145148 } ) ( req , res , next ) ;
146149} ) ;
147150
148151// callback for the OpenID Connect identity provider
149152// in the case of an error go back to authentication
150153app . get ( '/redirect_uri' , ( req , res , next ) => {
151154 passport . authenticate ( 'oidc' , {
152- redirect_uri : req . secure ? 'https ' : 'http' + `://${ req . headers . host } /redirect_uri` ,
155+ redirect_uri : ` ${ DEBUG_FLAG ? 'http ' : 'https' } ` + `://${ req . headers . host } /redirect_uri` ,
153156 successRedirect : '/' ,
154157 failureRedirect : '/authtest'
155158 } ) ( req , res , next ) ;
@@ -169,14 +172,24 @@ var checkAuthenticated = (req, res, next) => {
169172//
170173
171174// The index document already is protected
172- app . use ( '/' , checkAuthenticated , express . static ( __dirname + '/public' ) ) ;
175+ app . use ( '/secure ' , checkAuthenticated , express . static ( __dirname + '/public' ) ) ;
173176
174177
175178// Makes sure that all requests to /api are authenticated
176179app . use ( '/api/' , checkAuthenticated , ( req , res , next ) => {
177180 next ( ) ;
178181} ) ;
179182
183+ // Returns all files associated to the current user
184+ app . get ( '/health' , async function ( req , res ) {
185+ res . send ( req . headers ) ;
186+ } ) ;
187+
188+ app . get ( '/' , async function ( req , res ) {
189+ res . redirect ( "/secure" )
190+ } ) ;
191+
192+
180193
181194// Returns all files associated to the current user
182195app . get ( '/api/files' , async function ( req , res ) {
0 commit comments