@@ -29,6 +29,7 @@ var corsSettings = cors({
2929function  createApp  ( argv  =  { } )  { 
3030  var  ldp  =  new  LDP ( argv ) 
3131  var  app  =  express ( ) 
32+   var  oidcConfig  =  argv . oidc 
3233
3334  // check if we have master ACL or not 
3435  var  masterAcl 
@@ -84,40 +85,14 @@ function createApp (argv = {}) {
8485  // Session 
8586  app . use ( session ( sessionSettings ) ) 
8687
87-   ldp . oidcConfig  =  { 
88-     issuer : 'https://anvil.local' , 
89-     client_id : '54f94171-de00-41fa-bba2-7da4f1c01fde' , 
90-     client_secret : 'aa3c819b16460632c516' , 
91-     redirect_uri : 'https://ldnode.local:8443/api/oidc/rp' 
92-   } 
93-   if  ( ldp . oidcConfig )  { 
88+   if  ( oidcConfig )  { 
9489    var  oidc  =  new  OidcProvider ( ) 
9590    // TODO: ensureTrustedClient is async, possible race condition on server 
9691    //   startup 
9792    debug . idp ( 'Initializing local/trusted client...' ) 
98-     oidc . ensureTrustedClient ( ldp . oidcConfig ) 
93+     oidc . ensureTrustedClient ( oidcConfig ) 
9994    app . locals . oidc  =  oidc 
100-     // app.use('/', oidc.authenticate.bind(oidc)) 
101-     app . use ( '/' , 
102-       oidc . loadAuthClient . bind ( oidc ) , 
103- 
104-       ( req ,  res ,  next )  =>  { 
105-         debug . oidc ( 'in authWithClient():' ) 
106-         if  ( ! req . oidcClient )  { 
107-           debug . oidc ( '   * No oidcClient found, next()' ) 
108-           return  next ( ) 
109-         } 
110-         const  client  =  req . oidcClient 
111-         const  verifyOptions  =  { 
112-           allowNoToken : true , 
113-           loadUserInfo : true 
114-         } 
115-         let  verifier  =  client . verifier ( verifyOptions ) 
116-         verifier ( req ,  res ,  next ) 
117-       } , 
118- 
119-       oidc . authSessionInit . bind ( oidc ) 
120-     ) 
95+     app . use ( '/' ,  oidc . authenticate ( ) . bind ( oidc ) ) 
12196    app . use ( '/api/oidc' ,  oidc . middleware ( corsSettings ) ) 
12297  } 
12398
0 commit comments