Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta #7

Merged
merged 15 commits into from
Jul 25, 2024
35 changes: 35 additions & 0 deletions .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release beta
on: workflow_dispatch
jobs:
release:
runs-on: ubuntu-20.04
steps:
- uses: pnpm/action-setup@v4
with:
version: 8

- name: Checkout source code
uses: actions/checkout@v2

- name: Install the dependencies
run: pnpm install

- name: Initialise the NPM config
run: pnpm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Initialize Git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "sourabpramanik"

- name: Log git status
run: git status

- name: Run release
run: pnpm release:beta
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

20 changes: 0 additions & 20 deletions .github/workflows/test.yml

This file was deleted.

26 changes: 12 additions & 14 deletions .release-it.beta.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
git:
requireCleanWorkingDir: true
requireCleanWorkingDir: false
requireUpstream: true
requireCommits: true
addUntrackedFiles: false
commit: true
commitMessage: "chore: beta release v${version}-beta.${increment}"
commitMessage: "chore: beta release v${version}"
tag: true
tagName: "v${version}-beta.${increment}"
tagName: "v${version}"
push: true

npm:
publish: true
publishPath: "."
publishConfig:
registry: "https://registry.npmjs.org/"

skipChecks: true

github:
release: true
releaseName: "Beta Release ${version}"

releaseName: "Beta Release ${version}-beta.${increment}"
releaseNotes: "auto-generate"

hooks:
before:init:

- git fetch --all

- |
if [ "$(git symbolic-ref --short HEAD)" != "beta" ]; then

echo "Not on beta branch"

exit 1
fi
- git pull origin beta

- pnpm install
- pnpm build


plugins:

'@release-it/conventional-changelog':
infile: './CHANGELOG.md'
preset:
name: 'conventionalcommits'

types:

- { type: 'feat', section: 'Features' }

- { type: 'feature', section: 'Features' }
- { type: 'fix', section: 'Bug Fixes' }
- { type: 'docs', section: 'Documentation' }
Expand All @@ -55,7 +53,9 @@ plugins:
writerOpts:
commitGroupsSort: |
(a, b) => {

const groupOrder = ['Features', 'Bug Fixes', 'Chores', 'Documentation', 'Refactor'];

return groupOrder.indexOf(a.title) - groupOrder.indexOf(b.title);
}
commitsSort: |
Expand All @@ -70,7 +70,5 @@ plugins:
return a.subject.localeCompare(b.subject);
}

increment:
release: 'beta'

increment: "conventional:prerelease"

3 changes: 1 addition & 2 deletions .release-it.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
git:
requireCleanWorkingDir: true
requireCleanWorkingDir: false
requireUpstream: true
requireCommits: true
addUntrackedFiles: false
Expand All @@ -19,7 +19,6 @@ npm:
github:
release: true
releaseName: "Release ${version}"
releaseNotes: "auto-generate"

hooks:
before:init:
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

> **Note: This plugin supports all versions of Payload CMS starting from version 3.0 and above.**

# PayloadCMS OAuth Plugin
# Authentication plugin for PayloadCMS
This plugin is designed to simplify the integration of multiple Open Authorization (OAuth) and OpenID Connect providers with Payload CMS. Developers can quickly and effortlessly set up authentication mechanisms by leveraging pre-configured providers.

## How it works?
Expand All @@ -19,29 +19,29 @@ A single user can have multiple accounts, but each account can be associated wit
If you already have a collection with the slug `accounts`, it can cause a conflict and prevent the plugin from integrating successfully. To avoid this issue, make sure to change the slug before integrating this plugin.

### Endpoints
For every provider with different protocols, the endpoints are already configured in the plugin. So any request that comes to the `/api/oauth/**/*` route will be handled by the plugin.
For every provider with different protocols, the endpoints are already configured in the plugin. So any request that comes to the `/api/oauth/**/*` route will be handled by the plugin.

### Signin UI component
The OAuth signin component is added to the signin page when you integrate the plugin. It can be customized by passing the relevant configuration options.
The auth signin component is added to the signin page when you integrate the plugin. It can be customized by passing the relevant configuration options.

## Usage

### Install the plugin
```bash
npm install plugin-payload-oauth
npm install payload-auth-plugin
```
Or
```bash
yarn add plugin-payload-oauth
yarn add payload-auth-plugin
```
Or
```bash
pnpm add plugin-payload-oauth
pnpm add payload-auth-plugin
```
### Create an OAuth app
In your desired provider, create an OAuth application. Depending on your provider, you will need to obtain the Client ID and Client Secret from the provider's console or dashboard. Please refer to the [providers list](https://github.com/sourabpramanik/plugin-payload-oauth?tab=readme-ov-file#list-of-active-and-upcoming-providers) for detailed instructions on configuring a specific provider.

For example:
For example:
To configure Google OAuth

1. Add the callback/redirect URL:
Expand All @@ -57,15 +57,17 @@ GOOGLE_CLIENT_SECRET=****************************
### Configure the plugin
Import the plugin in `src/payload.config.ts` and set up a provider:
```typescript
// --- rest of the imports

import { buildConfig } from 'payload/config'
import AuthPlugin from 'plugin-payload-oauth'
import { GoogleAuthProvider } from 'plugin-payload-oauth/providers'
// --- rest of the imports
import AuthPlugin from 'payload-auth-plugin'
import AuthPlugin from 'payload-auth-plugin'
import { GoogleAuthProvider } from 'payload-auth-plugin'

export default buildConfig({
// --- rest of the config
plugins: [
// --- rest of plugins
// --- rest of the plugins
AuthPlugin({
providers: [
GoogleAuthProvider({
Expand Down
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@payloadcms/payload-plugin-oauth",
"version": "0.0.0",
"name": "payload-auth-plugin",
"version": "0.1.0",
"type": "module",
"author": "Sourab Pramanik<[email protected]>",
"license": "MIT",
"homepage:": "https://github.com/sourabpramanik/plugin-payload-oauth",
"repository": "[email protected]:sourabpramanik/plugin-payload-oauth.git",
"description": "Oauth plugin for Payload CMS",
"homepage:": "https://github.com/sourabpramanik/payload-auth-plugin",
"repository": "[email protected]:sourabpramanik/payload-auth-plugin.git",
"description": "Authentication plugin for Payload CMS",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"keywords": [
Expand Down Expand Up @@ -41,8 +41,6 @@
"dev": "cd dev && cross-env NODE_OPTIONS=--no-deprecation next dev",
"build": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:esbuild",
"build:esbuild": "node esbuild.mjs",
"build": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:esbuild",
"build:esbuild": "node esbuild.js",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"test": "cd test && jest --config=./jest.config.js",
"lint": "eslint src",
Expand Down Expand Up @@ -97,4 +95,4 @@
"oauth4webapi": "^2.11.1",
"react-dom": "^19.0.0-rc-85acf2d195-20240711"
}
}
}
Loading