payload-zitadel-plugin 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +54 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  [![NPM](https://nodei.co/npm/payload-zitadel-plugin.png)](https://npmjs.org/package/payload-zitadel-plugin)
4
4
 
5
- plugin for [Payload CMS](https://payloadcms.com), which enables authentication via Zitadel IdP. It uses [NextAuth.js](https://next-auth.js.org) under the hood.
5
+ plugin for [Payload CMS](https://payloadcms.com), which enables authentication via Zitadel IdP. It
6
+ uses [NextAuth.js](https://next-auth.js.org) under the hood.
6
7
 
7
8
  :boom: :boom: :boom:   works :100: with PayloadCMS version :three:   :boom: :boom: :boom:
8
9
 
@@ -23,24 +24,35 @@ import {buildConfig} from 'payload/config'
23
24
  import {ZitadelPluginProvider} from 'payload-zitadel-plugin'
24
25
 
25
26
  export const {zitadelPlugin, nextauthHandler} = ZitadelPluginProvider({
26
- // interpolation text for the Login Button
27
- externalProviderName: 'Test-IdP',
28
-
29
- // set to true if you want users to only be able to sign in via Zitadel
30
- disableLocalStrategy: true,
31
-
32
27
  // in Zitadel create a new App->Web->PKCE
33
28
  issuerUrl: process.env.ZITADEL_URL,
34
29
  clientId: process.env.ZITADEL_CLIENT_ID,
35
-
30
+
31
+ // interpolation text for the Login Button - "sign in with ..."
32
+ // externalProviderName: 'ZITADEL',
33
+
34
+ // set to true if you want to use your own custom login button
35
+ // disableDefaultLoginButton: true
36
+
37
+ // set to true if you want users to only be able to sign in via Zitadel
38
+ // disableLocalStrategy: true,
39
+
40
+ // if you want to specify the users collection slug
41
+ // authSlug: 'users',
42
+
43
+ // if you want to specify the field name for the IdP Id in the users collection
44
+ // associatedIdFieldName: 'idp_id'
45
+
46
+ // change the internal name, only if you know what you are doing!!!
47
+ // internalProviderName = 'zitadel',
48
+
36
49
  // following properties are only needed if you want to authenticate clients for the API
37
50
  // if you are just using the CMS you can ignore all of them
38
-
39
51
  // in Zitadel create a new App->API->JWT
40
- enableAPI: true,
41
- apiClientId: process.env.ZITADEL_API_CLIENT_ID,
42
- apiKeyId: process.env.ZITADEL_API_KEY_ID,
43
- apiKey: process.env.ZITADEL_API_KEY
52
+ // enableAPI: true,
53
+ // apiClientId: process.env.ZITADEL_API_CLIENT_ID,
54
+ // apiKeyId: process.env.ZITADEL_API_KEY_ID,
55
+ // apiKey: process.env.ZITADEL_API_KEY
44
56
  })
45
57
 
46
58
  export default buildConfig({
@@ -53,8 +65,12 @@ export default buildConfig({
53
65
  ```
54
66
 
55
67
  Optionally you could use an `.env.local` file for parameters:
68
+
56
69
  #### .env.local
70
+
57
71
  ```dotenv
72
+ NEXTAUTH_URL: 'http://localhost',
73
+ NEXTAUTH_SECRET: 'mQ46qpFwfE1BHuqMC+qlm19qBAD9fVPgh28werwe3ASFlAfnKjM=',
58
74
  ZITADEL_URL: 'https://idp.zitadel.url',
59
75
  ZITADEL_CLIENT_ID: '123456789012345678@project_name',
60
76
  ZITADEL_API_CLIENT_ID: '123456789123456789@project_name',
@@ -62,10 +78,35 @@ ZITADEL_API_KEY_ID: '123456789012345678',
62
78
  ZITADEL_API_KEY: '-----BEGIN RSA PRIVATE KEY----- ... ----END RSA PRIVATE KEY-----'
63
79
  ```
64
80
 
81
+ or use the Next.js Config file:
82
+
83
+ #### next.config.mjs
84
+
85
+ ```typescript
86
+ import {withPayload} from '@payloadcms/next/withPayload'
87
+
88
+ /** @type {import('next').NextConfig} */
89
+ const nextConfig = {
90
+ env: {
91
+ NEXTAUTH_URL: 'http://localhost',
92
+ NEXTAUTH_SECRET: 'mQ46qpFwfE1BHuqMC+qlm19qBAD9fVPgh28werwe3ASFlAfnKjM=',
93
+ ZITADEL_URL: 'https://idp.zitadel.url',
94
+ ZITADEL_CLIENT_ID: '123456789012345678@project_name',
95
+ ZITADEL_API_CLIENT_ID: '123456789123456789@project_name',
96
+ ZITADEL_API_KEY_ID: '123456789012345678',
97
+ ZITADEL_API_KEY: '-----BEGIN RSA PRIVATE KEY----- ... ----END RSA PRIVATE KEY-----'
98
+ }
99
+ }
100
+
101
+ export default withPayload(nextConfig)
102
+ ```
103
+
65
104
  ### create route
105
+
66
106
  Unfortunately you need to manually create the following NextAuth.js route in your Next.js App (using App Router):
67
107
 
68
108
  ### (nextauth)/api/auth/[...nextauth]/route.ts
109
+
69
110
  ```typescript
70
111
  import {nextauthHandler} from '@payload-config'
71
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload-zitadel-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "plugin for Payload CMS, which enables authentication via Zitadel IdP",
5
5
  "type": "module",
6
6
  "license": "MIT",