gousta

payload plugin oidc

by gousta
Authentication & SSO
v2
^2.0.13
MIT

Overview

Summary generated from the README

Adds OpenID Connect sign-in to Payload 2.x. A sign-in button is added to the admin login page, and the plugin registers init and callback endpoints for the OIDC flow. Users are matched in a chosen auth collection by a search key and can optionally be created when not found. Requires Payload 2.0.13 or newer.

Features

  • Sign-in button on the login page, placed before or after the login form
  • Configurable authorization, token, init and callback paths
  • Custom userinfo function to map provider data such as role onto the user
  • Optional creation of users when no match is found
  • Custom button component support

Use cases

  • Let staff log in to the Payload admin through a company identity provider
  • Assign Payload user roles from custom claims returned by the OIDC provider

From the author

OIDC plugin for Payload 2.0

Installation

npm i payload-plugin-oidc

36

Stars

7

Forks

1

Open Issues

1 years ago

Last Updated

158

Weekly Downloads

v1.52.0

npm Version

31.9 KB

Unpacked Size

7

Dependencies

GitHub stars

36+1 since Sep 6

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

108+73 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 2026108
Dec 4, 202620
Dec 3, 202615
Dec 2, 202615
Dec 1, 202623
Nov 30, 202629
Nov 29, 202692
Nov 28, 202699
Nov 27, 2026105
Nov 26, 2026110
Nov 25, 2026158
Nov 24, 2026163
Nov 23, 2026157
Nov 22, 202696
Nov 21, 202694
Nov 20, 202691
Nov 19, 202688
Nov 18, 202638
Nov 17, 202625
Nov 16, 202626
Nov 15, 202633
Nov 14, 202632
Nov 13, 202629
Nov 12, 202641
Nov 11, 202641
Nov 10, 202642
Nov 9, 202679
Nov 8, 202674
Nov 7, 202679
Nov 6, 202678
Nov 5, 202668
Nov 4, 202670
Nov 3, 202672
Nov 2, 202635
Nov 1, 202639
Oct 31, 202641
Oct 30, 202649
Oct 29, 202644
Oct 28, 202642
Oct 27, 202642
Oct 26, 202641
Oct 25, 202633
Oct 24, 202634
Oct 23, 202623
Oct 22, 202642
Oct 21, 202648
Oct 20, 202648
Oct 19, 202655
Oct 18, 202654
Oct 17, 202662
Oct 16, 202668
Oct 15, 2026157
Oct 14, 2026152
Oct 13, 2026150
Oct 12, 2026141
Oct 11, 2026181
Oct 10, 2026176
Oct 9, 2026170
Oct 8, 202667
Oct 7, 202668
Oct 6, 202669
Oct 5, 202674
Oct 4, 202642
Oct 3, 202639
Oct 2, 202643
Oct 1, 202639
Sep 30, 202673
Sep 29, 2026123
Sep 28, 2026117
Sep 27, 2026113
Sep 26, 2026109
Sep 25, 2026111
Sep 24, 2026111
Sep 23, 202676
Sep 22, 202670
Sep 21, 202672
Sep 20, 202678
Sep 19, 202678
Sep 18, 202675
Sep 17, 202676
Sep 16, 202678
Sep 15, 202635
Sep 14, 202635
Sep 13, 202633
Sep 12, 202633
Sep 11, 202638
Sep 10, 202638
Sep 9, 202637
Sep 8, 202635
Sep 7, 202635
Sep 6, 202635

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

Health Score

46/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/708338207-root.svg)](https://payloaddirectory.dev/plugins/708338207-root)
HTML
<a href="https://payloaddirectory.dev/plugins/708338207-root"><img src="https://payloaddirectory.dev/badge/708338207-root.svg" alt="Payload Directory"></a>
Updated Jun 12, 2025Created Oct 22, 2023Published Jun 12, 2025

README

OIDC plugin for Payload CMS

Software License Issues NPM

Features

  • Adds ability to sign in with your own OIDC provider
  • Adds sign in button on login page
  • Supports sign in and optional creation of user

Installation

npm install payload-plugin-oidc
# or
yarn add payload-plugin-oidc

Usage

// payload.config.ts
import { oidcPlugin } from 'payload-plugin-oidc';

export default buildConfig({
  serverURL: process.env.SERVER_URL,
  collections: [Users],
  plugins: [
    oidcPlugin({
      clientID: process.env.OIDC_CLIENT_ID,
      clientSecret: process.env.OIDC_CLIENT_SECRET,
      authorizationURL: `${process.env.OIDC_URI}/oidc/auth`,
      tokenURL: `${process.env.OIDC_URI}/oidc/token`,
      initPath: `/oidc/signin`,
      callbackPath: `/oidc/callback`,
      callbackURL: `${process.env.SELF_URL}/oidc/callback`,
      scope: 'openid offline_access profile email custom_data',
      components: {
        Button: SignInButton, //can be your own custom component
        position: "beforeLogin" //beforeLogin | afterLogin
      },
      userCollection: {
        slug: Users.slug,
        searchKey: 'email',
      },
      createUserIfNotFound: true,
      async userinfo(accessToken) {
        const { data: user } = await axios.get(`${process.env.OIDC_URI}/oidc/me`, {
          headers: {
            Authorization: `Bearer ${accessToken}`,
          },
        });

        return {
          sub: user.sub,
          name: user.name,
          email: user.email,
          // You can use OIDC user custom data to get the role for this app
          role: user.custom_data?.my_app_role,

          // or you can do something like this
          // role: user.custom_data?.role ? 'admin' : 'editor',
        };
      },
    }),
  ],
});

Contributing

Contributions and feedback are very welcome.

To get it running:

  1. Clone the project.
  2. npm install
  3. npm run build

License

The MIT License (MIT). Please see License File for more information.

Similar plugins