Search code examples
javascriptnode.jspassport.jsrestful-authenticationokta

Okta with Passport.js or not?


I was looking into improving my sing-up and login workflows and I looked into Okta.

At the moment we are using passport with our custom database and customs strategies and sessions remote storage. It seems like Okta can be used on its own. I did find some custom libraries online to use it with Passport.js. I don't see why you would tough.

Anyone has any experience with Okta and any opinion on why you would use it with passport ?

Here is a passport library to work with okta: https://github.com/techstars/passport-okta-oauth-example/blob/master/config/passport.js

Here is a "simple" way of using okta: https://developer.okta.com/quickstart/#/okta-sign-in-page/nodejs/express


Solution

  • The two links you shared does the same thing. Mainly, get id or access token.

    The Signin widget can establish a session and get the token via this config:

    Application Name    My Web App
    Base URIs   http://localhost:{port}
    Login redirect URIs http://localhost:{port}/authorization-code/callback
    Grant Types Allowed Authorization Code
    

    the other link you shared gets the same token via this config:

    passport.use(new OktaStrategy({
        audience:     nconf.get("OKTA_AUDIENCE"),
        clientID:     nconf.get("OKTA_CLIENTID"),
        clientSecret: nconf.get("OKTA_CLIENTSECRET"),
        idp:          nconf.get("OKTA_IDP"),
        scope: ['openid', 'email', 'profile'],
        response_type: 'code',
        callbackURL: "http://localhost:3000/auth/okta/callback"
      }
    

    so you should not need to use both of them.