11const express = require ( "express" ) ;
22const app = express ( ) ;
3+ const fs = require ( 'fs' ) ;
4+ const https = require ( 'https' ) ;
35var path = require ( 'path' ) ;
46const XMLHttpRequest = require ( 'xmlhttprequest' ) . XMLHttpRequest
57
@@ -15,19 +17,36 @@ app.set('views', path.join(__dirname, 'views'));
1517app . set ( 'view engine' , 'html' ) ;
1618
1719app . get ( '/' , function ( req , res ) {
18- let id = default_if_blank ( req . query . client_id , client_id ) ;
19- let secret = default_if_blank ( req . query . client_secret , client_secret ) ;
20- res . render ( 'rabbitmq' , {
21- proxied_url : proxied_rabbitmq_url ,
22- url : rabbitmq_url . replace ( / \/ ? $ / , '/' ) + "login" ,
23- name : rabbitmq_url + " for " + id ,
24- access_token : access_token ( id , secret )
25- } ) ;
26- } ) ;
20+ let id = default_if_blank ( req . query . client_id , client_id )
21+ let secret = default_if_blank ( req . query . client_secret , client_secret )
22+ if ( id == 'undefined' || secret == 'undefined' ) {
23+ res . render ( 'unauthenticated' )
24+ } else {
25+ res . render ( 'rabbitmq' , {
26+ proxied_url : proxied_rabbitmq_url ,
27+ url : rabbitmq_url . replace ( / \/ ? $ / , '/' ) + "login" ,
28+ name : rabbitmq_url + " for " + id ,
29+ access_token : access_token ( id , secret )
30+ } )
31+ }
32+ } )
33+
2734app . get ( '/favicon.ico' , ( req , res ) => res . status ( 204 ) ) ;
2835
36+ app . get ( '/logout' , function ( req , res ) {
37+ res . redirect ( uaa_url + '/logout.do?redirect=' + req . protocol + '://' + req . get ( 'host' ) + "/" ) ;
38+ } )
39+
40+ https
41+ . createServer (
42+ {
43+ cert : fs . readFileSync ( '/etc/fakeportal/server_fakeportal_certificate.pem' ) ,
44+ key : fs . readFileSync ( '/etc/fakeportal/server_fakeportal_key.pem' )
45+ } ,
46+ app
47+ )
48+ . listen ( port )
2949
30- app . listen ( port ) ;
3150console . log ( 'Express started on port ' + port ) ;
3251
3352function default_if_blank ( value , defaultValue ) {
0 commit comments