finkinfridom

payload auth0 plugin

by finkinfridom
Authentication & SSO
v2
^2.30.3
MIT

Overview

Summary generated from the README

Adds Auth0 login to Payload through a custom auth strategy attached to an auth collection. It works with express-openid-connect on the server and provides a login button, an avatar component and a picture field for the admin panel. It targets Payload 2.x and needs Auth0 client credentials and callback routes configured.

Features

  • Auth0 strategy class for a Payload auth collection
  • Login button component shown after the admin login form
  • Auth0 avatar component for the admin header
  • Picture UI field that displays the Auth0 profile image
  • Stores the Auth0 sub identifier on the user document
  • Configurable login, logout and callback routes

Use cases

  • Let editors sign in to the Payload admin with their Auth0 accounts
  • Centralize admin user identity in an existing Auth0 tenant

From the author

Extends payloadcms with Auth0 integration

Installation

npm i payload-auth0-plugin

62

Stars

5

Forks

16

Open Issues

9 months ago

Last Updated

84

Weekly Downloads

v0.1.15

npm Version

148.3 KB

Unpacked Size

6

Dependencies

GitHub stars

620 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 202662
Dec 5, 202662
Dec 4, 202662
Dec 3, 202662
Dec 2, 202662
Dec 1, 202662
Nov 30, 202662
Nov 29, 202662
Nov 28, 202662
Nov 27, 202662
Nov 26, 202662
Nov 25, 202662
Nov 24, 202662
Nov 23, 202662
Nov 22, 202662
Nov 21, 202662
Nov 20, 202662
Nov 19, 202662
Nov 18, 202662
Nov 17, 202662
Nov 16, 202662
Nov 15, 202662
Nov 14, 202662
Nov 13, 202662
Nov 12, 202662
Nov 11, 202662
Nov 10, 202662
Nov 9, 202662
Nov 8, 202662
Nov 7, 202662
Nov 6, 202662
Nov 5, 202662
Nov 4, 202662
Nov 3, 202662
Nov 2, 202662
Nov 1, 202662
Oct 31, 202662
Oct 30, 202662
Oct 29, 202662
Oct 28, 202662
Oct 27, 202662
Oct 26, 202662
Oct 25, 202662
Oct 24, 202662
Oct 23, 202662
Oct 22, 202662
Oct 21, 202662
Oct 20, 202662
Oct 19, 202662
Oct 18, 202662
Oct 17, 202662
Oct 16, 202662
Oct 15, 202662
Oct 14, 202662
Oct 13, 202662
Oct 12, 202662
Oct 11, 202662
Oct 10, 202662
Oct 9, 202662
Oct 8, 202662
Oct 7, 202662
Oct 6, 202662
Oct 5, 202662
Oct 4, 202662
Oct 3, 202662
Oct 2, 202662
Oct 1, 202662
Sep 30, 202662
Sep 29, 202662
Sep 28, 202662
Sep 27, 202662
Sep 26, 202662
Sep 25, 202662
Sep 24, 202662
Sep 23, 202662
Sep 22, 202662
Sep 21, 202662
Sep 20, 202662
Sep 19, 202662
Sep 18, 202662
Sep 17, 202662
Sep 16, 202662
Sep 15, 202662
Sep 14, 202662
Sep 13, 202662
Sep 12, 202662
Sep 11, 202662
Sep 10, 202662
Sep 9, 202662
Sep 8, 202662
Sep 7, 202662
npm weekly downloads

84−36 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202684
Dec 5, 202667
Dec 4, 202629
Dec 3, 202630
Dec 2, 202629
Dec 1, 202630
Nov 30, 202631
Nov 29, 202648
Nov 28, 202648
Nov 27, 202647
Nov 26, 202646
Nov 25, 202655
Nov 24, 202654
Nov 23, 202653
Nov 22, 202643
Nov 21, 202647
Nov 20, 202699
Nov 19, 2026107
Nov 18, 2026114
Nov 17, 2026114
Nov 16, 2026116
Nov 15, 2026107
Nov 14, 2026100
Nov 13, 202649
Nov 12, 202650
Nov 11, 202633
Nov 10, 202635
Nov 9, 202654
Nov 8, 202651
Nov 7, 202651
Nov 6, 202647
Nov 5, 202636
Nov 4, 202634
Nov 3, 202633
Nov 2, 202613
Nov 1, 202613
Oct 31, 202613
Oct 30, 202620
Oct 29, 202618
Oct 28, 202616
Oct 27, 202617
Oct 26, 202626
Oct 25, 202626
Oct 24, 202627
Oct 23, 202618
Oct 22, 202620
Oct 21, 202620
Oct 20, 202618
Oct 19, 20268
Oct 18, 20267
Oct 17, 20269
Oct 16, 202623
Oct 15, 202667
Oct 14, 202680
Oct 13, 202680
Oct 12, 202680
Oct 11, 2026100
Oct 10, 2026116
Oct 9, 2026134
Oct 8, 2026107
Oct 7, 2026104
Oct 6, 2026104
Oct 5, 2026104
Oct 4, 2026108
Oct 3, 2026113
Oct 2, 2026100
Oct 1, 202688
Sep 30, 202699
Sep 29, 2026119
Sep 28, 2026119
Sep 27, 2026106
Sep 26, 202690
Sep 25, 202692
Sep 24, 2026109
Sep 23, 2026112
Sep 22, 2026112
Sep 21, 2026123
Sep 20, 2026128
Sep 19, 2026122
Sep 18, 2026108
Sep 17, 202695
Sep 16, 202682
Sep 15, 202662
Sep 14, 202654
Sep 13, 202659
Sep 12, 202691
Sep 11, 2026126
Sep 10, 2026119
Sep 9, 2026118
Sep 8, 2026118
Sep 7, 2026120

Each point is npm's rolling 7-day download count.

Health Score

39/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/551363564-root.svg)](https://payloaddirectory.dev/plugins/551363564-root)
HTML
<a href="https://payloaddirectory.dev/plugins/551363564-root"><img src="https://payloaddirectory.dev/badge/551363564-root.svg" alt="Payload Directory"></a>
Updated Feb 12, 2026Created Oct 14, 2022Published Sep 2, 2024

README

payload-auth0-plugin

Extends payloadcms with Auth0 integration

Current status

codeql

test

publish

GitHub Super-Linter

Codacy Badge

Codacy Badge

Install

yarn add payload-auth0-plugin

Get Started

server.ts

import { auth } from "express-openid-connect";
const config = {
  authRequired: false,
  idpLogout: true,
  auth0Logout: true,
  baseURL: process.env.REACT_APP_SERVER_BASE_URL,
  clientID: process.env.AUTH0_CLIENT_ID,
  clientSecret: process.env.AUTH0_CLIENT_SECRET,
  issuerBaseURL: process.env.AUTH0_DOMAIN,
  secret: "<LONG_RANDOM_STRING>",
  routes: {
    login: process.env.REACT_APP_AUTH0_LOGIN_URL,
    logout: process.env.REACT_APP_AUTH0_LOGOUT_URL,
    callback: process.env.AUTH0_CALLBACK_URL,
  },
};
app.use(auth(config));

REACT_APP env variables

REACT_APP_SERVER_BASE_URL=http://localhost:3000
REACT_APP_AUTH0_LOGIN_URL=/auth0/login # the one you set up in Auth0
REACT_APP_AUTH0_LOGOUT_URL=/auth0/logout # the one you set up in Auth0
AUTH0_CALLBACK_URL=/auth0/callback # the one you set up in Auth0

payload.config.ts

import Auth0Avatar from from "payload-auth0-plugin/dist/components/Auth0Avatar";
import { LoginButton } from "payload-auth0-plugin/dist/components";

export default buildConfig({
    ....
    admin: {
        avatar: Auth0Avatar,
        logoutRoute: process.env.REACT_APP_AUTH0_LOGOUT_URL,
        inactivityRoute: process.env.REACT_APP_INACTIVITY_URL,
        components: {
            afterLogin: [LoginButton()],
        },
    }
})

your-auth-collection.ts

import { Auth0Strategy } from "payload-auth0-plugin";
import { PictureField } from "payload-auth0-plugin/dist/components";

const MyAuthCollection: CollectionConfig = {
  slug: "authCollection",
  auth: {
    strategies: [
      {
        name: Auth0Strategy.name,
        strategy: (ctx) => {
          return new Auth0Strategy(ctx, "authCollection");
        },
      },
    ],
  },
  fields: [
    {
      name: "picture",
      type: "text",
      admin: {
        hidden: true,
        condition: (data) => {
          return data.picture;
        },
      },
    },
    {
      name: "pictureVisual",
      type: "ui",
      admin: {
        position: "sidebar",
        condition: (_, siblingData) => {
          return siblingData.picture;
        },
        components: {
          Field: PictureField,
          Cell: PictureField,
        },
      },
    },
    {
      name: "sub",
      type: "text",
      admin: {
        readOnly: true,
        condition: (data) => {
          return data.sub;
        },
      },
    },
  ],
};

Similar plugins