Giter Site home page Giter Site logo

passport-okta-oauth20's Introduction

passport-okta-oauth20

GitHub package.json version Licence Code Quality Maintenance

Okta OAuth 2.0 provider for Passport with TypeScript support.

Installation

npm i passport-okta-oauth20 or yarn add passport-okta-oauth20.

Usage

import { Strategy as OktaStrategy } from 'passport-okta-oauth20';

passport.use(
  new OktaStrategy(
    {
      audience: 'https://acme.okta.com',
      clientID: 'oa6qp1vkvrgwABC12345',
      clientSecret: 'qwertyA-fooBazB_DQSS-qqsQSD123',
      scope: ['openid', 'email', 'profile'],
      callbackURL: 'http://localhost:3000/api/auth/okta/callback',
    },
    function (accessToken, refreshToken, profile, done) {
      // Do something with the profile
      return done(null, profile);
    }
  )
);

Custom Authorisation Server

You can also specify the property authorizationId to turn the authorizationURL from https://acme.okta.com/oauth2/v1/authorize to https://acme.okta.com/oauth2/foobar/v1/authorize if:

  • authorizationId is foobar, and
  • audience is https://acme.okta.com

This is optional.

Profile

{
  id: 'azerty12345890',
  displayName: 'Adam Smith',
  username: '[email protected]',
  fullName: 'Adam Smith',
  familyName: 'Smith',
  givenName: 'Adam',
  email: '[email protected]',
  zoneInfo: 'America/Los_Angeles',
  updatedAt: 1625319840,
  emailVerified: true,
  locale: 'en-US',
  _raw: '{"sub":"azerty12345890", ...',
  _json: Object // Raw response from Okta
}

TypeScript

If you are using TypeScript, you can import the following types:

import { OktaProfile, OktaStrategyOptions } from 'passport-okta-oauth20'

Change Log

Version 1.1.0

  • Adding an optional parameter, authorizationId, to use a custom authorisation server. ๐Ÿ‘ Thanks @fpunny for the PR (#6).
  • โซ Upgrading dependencies

Version 1.0.1

  • Testing on Node 12, 14 and 16
  • Replace .npmignore by a whitelist (files) in package.json
  • Restrict to Node >= 12 (but will probably work with older version.)
  • Testing both the original TypeScript code and the transpiled JS code

Version 1.0.0

  • Functional parity with passport-okta-oauth
  • Full TypeScript support
  • Simplified logic and up-to-date dependencies
  • Very lightweight NPM package (6.2 kB)
  • Test coverage
  • Linting

Prior art

This repository is loosely based on passport-okta-oauth.

That repository was archived a while ago, and this rewrite brings the following changes:

  • Full native TypeScript support
  • Simplified logic
  • Using node-fetch for fetching the profile instead of a private function from oauth.
  • Update to the user profile (Okta added new fields that were not present in the original library)
  • Unit testing
  • Linting
  • CI

passport-okta-oauth20's People

Contributors

antoinejaussoin avatar

Stargazers

Steven Kessler avatar

Watchers

 avatar  avatar

Forkers

fpunny

passport-okta-oauth20's Issues

missing authenticate function for typescript

Hey there,

before I start, thanks for your work!

The strategy is not working correct if I use it with the latest passport typings and typescript . TS is complaining about missing authentication in the strategy typing as this is not provided by passport-oauth as it has no typings at all.

Would be nice if this could be fixed!

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.