ibm-cloud-security / appid-serversdk-nodejs

Node.js SDK for the IBM Cloud App ID service
Apache License 2.0
29 stars 35 forks source link

Cannot access /protected in provided WebAppSample "Protecting web applications using WebAppStrategy" #269

Open stepoibm opened 2 years ago

stepoibm commented 2 years ago

Hi! I'm having trouble getting the example to work. The returned token from the appID login don't seem to persist in the session or in a cookie, so I can't ever access the "protected" endpoint. Am I missing something?

Reproduction steps

  1. install required packages npm install --save ibmcloud-appid log4js passport express-session express pug
  2. get sample folder from this repo
  3. save provided example as server.js
  4. replace this in server.js with data from existing appid instance
    passport.use(new WebAppStrategy({
    tenantId: "{tenant-id}",
    clientId: "{client-id}",
    secret: "{secret}",
    oauthServerUrl: "{oauth-server-url}",
    redirectUri: "{app-url}" + CALLBACK_URL
    }));
  5. register callback uri with appid (for me http://localhost:3000/ibm/bluemix/appid/callback)
  6. run node server.js
  7. navigate to http://localhost:3000/web-app-sample.html
  8. click "open protected page"
  9. login
  10. navigate to http://localhost:3000/web-app-sample.html
  11. click "open protected page"

Expected

  1. http://localhost:3000/web-app-sample.html should not show "You're not authenticated :(" after logging in in step 10
  2. after login I should be able to access /protected

Additional

stepoibm commented 2 years ago

@VadimDez discovered, that the issue does not exist for passport version 0.5.3. Current version is 0.6.0

jay-mack commented 1 year ago

@stepoibm A new version of the SDK has been released, v7, this includes revised samples of AppID working with passport v6. You mostly likely will need to make changes to your application so play around with the examples.