Skip to content

loomhq/passport-workos

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Passport WorkOS

A passport strategy for WorkOS SSO.

Installation

npm i passport-workos passport @workos-inc/node

Usage

Import the strategy.

import { WorkOSSSOStrategy } from "passport-workos";

Instantiate it with your WorkOS credentials, callbackURL, and verify function.

passport.use(
  "workos",
  new WorkOSSSOStrategy(
    {
      clientID: process.env.WORKOS_CLIENT_ID,
      clientSecret: process.env.WORKOS_API_KEY,
      callbackURL: "http://localhost:3000/auth/workos/callback",
    },
    (req, accessToken, refreshToken, profile, done) => {
      return done(undefined, profile);
      // console.log(args);
    }
  )
);

Add a callback handler for your login route.

app.get("/login", passport.authenticate("workos"));

Add a callback handler for your callback route.

app.get(
  "/auth/workos/callback",
  passport.authenticate("workos"),
  (req, res) => {
    // Do something once authenticated
    // ..
    res.redirect("/");
  }
);

Login route

The login route takes any of the arguments specified here.

There's an additional email parameter which the strategy will, in turn, derive the domain value.

About

Passport strategy for WorkOS SSO

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%