Socket
Socket
Sign inDemoInstall

payload-plugin-oauth

Package Overview
Dependencies
5
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    payload-plugin-oauth

<img src="https://img.shields.io/github/issues/thgh/payload-plugin-oau


Version published
Weekly downloads
387
decreased by-42.15%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

oAuth plugin for Payload CMS

Software License Issues NPM

Features

  • Configures passport-oauth2
  • Mounts authorize & callback route
  • Adds sign in button on login page

Installation

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

Usage

// payload.config.ts
import { oAuthPlugin } from 'payload-plugin-oauth'

export default buildConfig({
  serverURL: process.env.SERVER_URL,
  collections: [Users],
  plugins: [
    oAuthPlugin({
      clientID: process.env.CLIENT_ID,
      clientSecret: process.env.CLIENT_SECRET,
      authorizationURL: process.env.OAUTH_SERVER + '/oauth/authorize',
      tokenURL: process.env.OAUTH_SERVER + '/oauth/token',
      callbackURL: process.env.SERVER_URL + '/oauth2/callback',
      scope: 'basic',
      async userinfo(accessToken) {
        const { data: user } = await axios.get(OAUTH_SERVER + '/oauth/me', {
          params: { access_token: accessToken },
        })
        return {
          sub: user.ID,

          // Custom fields to fill in if user is created
          name: user.display_name || user.user_nicename || 'Naamloos',
          email: user.user_email,
          role: user.capabilities?.administrator ? 'admin' : 'user',
        }
      },
    }),
  ],
})

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Contributions and feedback are very welcome.

To get it running:

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

Credits

License

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

FAQs

Last updated on 06 Apr 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc