@@ -59,7 +59,8 @@ async function configureOIDC(req, res, next) {
59
59
const issuer = await Issuer . discover ( APPID_OAUTH_SERVER_URL ) // connect to oidc application
60
60
const client = new issuer . Client ( { // Initialize issuer information
61
61
client_id : APPID_CLIENT_ID ,
62
- client_secret : APPID_SECRET
62
+ client_secret : APPID_SECRET ,
63
+ redirect_uris : [ APPID_APP_URL + '/redirect_uri' , 'http://sfs.4loeser.net/redirect_uri' , 'http://0.0.0.0:8081/redirect_uri' ]
63
64
} ) ;
64
65
const params = {
65
66
redirect_uri : APPID_APP_URL + '/redirect_uri' ,
@@ -71,7 +72,7 @@ async function configureOIDC(req, res, next) {
71
72
req . app . authClient = client ;
72
73
73
74
// Register oidc strategy with passport
74
- passport . use ( 'oidc' , new Strategy ( { client, params } , ( tokenset , userinfo , done ) => {
75
+ passport . use ( 'oidc' , new Strategy ( { client } , ( tokenset , userinfo , done ) => {
75
76
return done ( null , userinfo ) ; // return user information
76
77
} ) ) ;
77
78
@@ -122,7 +123,7 @@ var cosUrlGenerator = new CloudObjectStorage.S3({
122
123
123
124
// serialize and deserialize the user information
124
125
passport . serializeUser ( function ( user , done ) {
125
- console . log ( "Got authenticated user" , JSON . stringify ( user ) ) ;
126
+ // console.log("Got authenticated user", JSON.stringify(user));
126
127
done ( null , {
127
128
id : user [ "id" ] ,
128
129
name : user [ "name" ] ,
@@ -139,13 +140,16 @@ app.use(configureOIDC);
139
140
140
141
// default protected route /authtest
141
142
app . get ( '/authtest' , ( req , res , next ) => {
142
- passport . authenticate ( 'oidc' ) ( req , res , next ) ;
143
+ passport . authenticate ( 'oidc' , {
144
+ redirect_uri : `http://${ req . headers . host } /redirect_uri` ,
145
+ } ) ( req , res , next ) ;
143
146
} ) ;
144
147
145
148
// callback for the OpenID Connect identity provider
146
149
// in the case of an error go back to authentication
147
150
app . get ( '/redirect_uri' , ( req , res , next ) => {
148
151
passport . authenticate ( 'oidc' , {
152
+ redirect_uri : `http://${ req . headers . host } /redirect_uri` ,
149
153
successRedirect : '/' ,
150
154
failureRedirect : '/authtest'
151
155
} ) ( req , res , next ) ;
0 commit comments