Socket
Book a DemoInstallSign in
Socket

passport-okta-id-token

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-okta-id-token

## Install

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

passport-okta-id-token

Install

npm install passport-okta-id-token

Usage

Strategy uses @okta/jwt-verifier under the hood.

Configure Strategy

The strategy requires verifier options and verify callback. Both arguments are required.

const { Strategy } = require("passport-okta-id-token");

passport.use(
  new Strategy({ issuer: "https://{yourOktaDomain}/oauth2/default" }, function (
    jwt,
    sub,
    done
  ) {
    User.findOrCreate({ oktaId: sub }, function (err, user) {
      return done(err, user);
    });
  })
);

Authenticate Requests

app.post(
  "/auth/okta",
  passport.authenticate("okta-id-token", {
    expectedClientId: "0oa5h93ocjgurRFu05d7",
    expectedNonce:
      "8V7Okhr8WqMGsXPQJaGy1Nu4GT5W05BfIbYlagBd587tryHKW6wWvQQiYvKFoZfJ",
    getIdTokenFromReq: (req) => req.body.id_token,
    session: false,
  }),
  function (req, res) {
    // do something with req.user
    res.sendStatus(req.user ? 200 : 401);
  }
);

FAQs

Package last updated on 23 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts