payload-zitadel-plugin 0.1.2 → 0.1.4
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.
- package/README.md +41 -5
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.d.ts.map +1 -0
- package/dist/components/Avatar/index.js +22 -0
- package/dist/components/Avatar/index.js.map +1 -0
- package/dist/components/LoginButton/button.d.ts +3 -0
- package/dist/components/LoginButton/button.d.ts.map +1 -0
- package/dist/components/LoginButton/button.js +21 -0
- package/dist/components/LoginButton/button.js.map +1 -0
- package/dist/components/LoginButton/index.d.ts.map +1 -0
- package/dist/components/LoginButton/index.js.map +1 -0
- package/dist/components/Session/index.d.ts +4 -0
- package/dist/components/Session/index.d.ts.map +1 -0
- package/dist/components/Session/index.js +6 -0
- package/dist/components/Session/index.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -6
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/dist/LoginButton/button.d.ts +0 -3
- package/dist/LoginButton/button.d.ts.map +0 -1
- package/dist/LoginButton/button.js +0 -20
- package/dist/LoginButton/button.js.map +0 -1
- package/dist/LoginButton/index.d.ts.map +0 -1
- package/dist/LoginButton/index.js.map +0 -1
- /package/dist/{LoginButton → components/LoginButton}/index.d.ts +0 -0
- /package/dist/{LoginButton → components/LoginButton}/index.js +0 -0
package/README.md
CHANGED
@@ -10,17 +10,16 @@ uses [NextAuth.js](https://next-auth.js.org) under the hood.
|
|
10
10
|
## Install
|
11
11
|
|
12
12
|
```shell
|
13
|
-
pnpm add payload-zitadel-plugin@0.1.
|
13
|
+
pnpm add payload-zitadel-plugin@0.1.3
|
14
14
|
```
|
15
15
|
|
16
16
|
## Configuration
|
17
17
|
|
18
18
|
Initialize the plugin in Payload Config File. Change the parameters to connect to your Zitadel Instance.
|
19
19
|
|
20
|
-
####
|
20
|
+
#### zitadel-plugin.ts
|
21
21
|
|
22
22
|
```typescript
|
23
|
-
import {buildConfig} from 'payload/config'
|
24
23
|
import {ZitadelPluginProvider} from 'payload-zitadel-plugin'
|
25
24
|
|
26
25
|
export const {zitadelPlugin, nextauthHandler} = ZitadelPluginProvider({
|
@@ -31,6 +30,9 @@ export const {zitadelPlugin, nextauthHandler} = ZitadelPluginProvider({
|
|
31
30
|
// interpolation text for the Login Button - "sign in with ..."
|
32
31
|
// externalProviderName: 'ZITADEL',
|
33
32
|
|
33
|
+
// set to true if you do not want to use the IdP Profile as the Avatar
|
34
|
+
// disableAvatar: true
|
35
|
+
|
34
36
|
// set to true if you want to use your own custom login button
|
35
37
|
// disableDefaultLoginButton: true
|
36
38
|
|
@@ -55,6 +57,13 @@ export const {zitadelPlugin, nextauthHandler} = ZitadelPluginProvider({
|
|
55
57
|
// apiKey: process.env.ZITADEL_API_KEY
|
56
58
|
})
|
57
59
|
|
60
|
+
```
|
61
|
+
|
62
|
+
#### payload.config.ts
|
63
|
+
|
64
|
+
```typescript
|
65
|
+
import {buildConfig} from 'payload/config'
|
66
|
+
|
58
67
|
export default buildConfig({
|
59
68
|
...,
|
60
69
|
plugins: [
|
@@ -80,7 +89,7 @@ ZITADEL_API_KEY='-----BEGIN RSA PRIVATE KEY----- ... ----END RSA PRIVATE KEY----
|
|
80
89
|
|
81
90
|
or use the Next.js Config file:
|
82
91
|
|
83
|
-
#### next.config.
|
92
|
+
#### next.config.js
|
84
93
|
|
85
94
|
```typescript
|
86
95
|
import {withPayload} from '@payloadcms/next/withPayload'
|
@@ -108,9 +117,36 @@ Unfortunately you need to manually create the following NextAuth.js route in you
|
|
108
117
|
### (nextauth)/api/auth/[...nextauth]/route.ts
|
109
118
|
|
110
119
|
```typescript
|
111
|
-
import {nextauthHandler} from '
|
120
|
+
import {nextauthHandler} from '@/config/zitadel-plugin'
|
112
121
|
|
113
122
|
export {nextauthHandler as GET, nextauthHandler as POST}
|
114
123
|
```
|
115
124
|
|
125
|
+
### add profile picture url to accepted Next.js assets
|
126
|
+
|
127
|
+
If you want to use the Zitadel profile picture as the avatar in PayloadCMS (`disableAvatar != true`),
|
128
|
+
you have to manually add the asset URL to the Next.js config file.
|
129
|
+
|
130
|
+
#### next.config.js
|
131
|
+
|
132
|
+
```typescript
|
133
|
+
import {withPayload} from '@payloadcms/next/withPayload'
|
134
|
+
|
135
|
+
/** @type {import('next').NextConfig} */
|
136
|
+
const nextConfig = {
|
137
|
+
images: {
|
138
|
+
remotePatterns: [
|
139
|
+
{
|
140
|
+
//protocol: new URL(process.env.ZITADEL_URL).protocol,
|
141
|
+
hostname: new URL(process.env.ZITADEL_URL).hostname,
|
142
|
+
//port: new URL(process.env.ZITADEL_URL).port,
|
143
|
+
pathname: '/assets/**'
|
144
|
+
}
|
145
|
+
]
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
export default withPayload(nextConfig)
|
150
|
+
```
|
151
|
+
|
116
152
|
## For an example look in this repository at the `dev` directory!
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/index.tsx"],"names":[],"mappings":""}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/*'use client'
|
2
|
+
|
3
|
+
import * as React from 'react'
|
4
|
+
import {useSession} from 'next-auth/react'
|
5
|
+
import {CustomComponent} from 'payload'
|
6
|
+
import {Thumbnail} from '@payloadcms/ui/elements/Thumbnail'
|
7
|
+
import {DefaultAccountIcon} from '@payloadcms/ui/graphics/Account/Default'
|
8
|
+
|
9
|
+
|
10
|
+
export const Avatar: CustomComponent = () => {
|
11
|
+
|
12
|
+
const session = useSession()
|
13
|
+
|
14
|
+
const imageUrl = session?.data?.user?.image
|
15
|
+
|
16
|
+
return imageUrl ? (
|
17
|
+
<div className="avatar">
|
18
|
+
<Thumbnail fileSrc={imageUrl} size="expand"/>
|
19
|
+
</div>
|
20
|
+
) : <DefaultAccountIcon active={false}/>
|
21
|
+
}*/
|
22
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Avatar/index.tsx"],"sourcesContent":["/*'use client'\n\nimport * as React from 'react'\nimport {useSession} from 'next-auth/react'\nimport {CustomComponent} from 'payload'\nimport {Thumbnail} from '@payloadcms/ui/elements/Thumbnail'\nimport {DefaultAccountIcon} from '@payloadcms/ui/graphics/Account/Default'\n\n\nexport const Avatar: CustomComponent = () => {\n\n const session = useSession()\n\n const imageUrl = session?.data?.user?.image\n\n return imageUrl ? (\n <div className=\"avatar\">\n <Thumbnail fileSrc={imageUrl} size=\"expand\"/>\n </div>\n ) : <DefaultAccountIcon active={false}/>\n}*/"],"names":[],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;;;;;;;;;;;;;;;;;;CAoBC,GApBD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/LoginButton/button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAMvC,eAAO,MAAM,YAAY,EAAE,eAe1B,CAAA"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
'use client';
|
2
|
+
import React from 'react';
|
3
|
+
import { signIn } from 'next-auth/react';
|
4
|
+
//import {NestedKeysStripped} from '@payloadcms/translations'
|
5
|
+
import { Button } from '@payloadcms/ui/client';
|
6
|
+
//import {useTranslation} from '@payloadcms/ui/providers/Translation'
|
7
|
+
//import {translations} from '../../translations.js'
|
8
|
+
export const _LoginButton = ({ internalProviderName, externalProviderName })=>{
|
9
|
+
//currently not working
|
10
|
+
//const {t} = useTranslation<typeof translations.en, NestedKeysStripped<typeof translations.en>>()
|
11
|
+
return /*#__PURE__*/ React.createElement("div", {
|
12
|
+
style: {
|
13
|
+
display: 'flex',
|
14
|
+
justifyContent: 'center'
|
15
|
+
}
|
16
|
+
}, /*#__PURE__*/ React.createElement(Button, {
|
17
|
+
onClick: ()=>signIn(internalProviderName)
|
18
|
+
}, externalProviderName));
|
19
|
+
};
|
20
|
+
|
21
|
+
//# sourceMappingURL=button.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LoginButton/button.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\nimport {signIn} from 'next-auth/react'\nimport {CustomComponent} from 'payload'\n//import {NestedKeysStripped} from '@payloadcms/translations'\nimport {Button} from '@payloadcms/ui/client'\n//import {useTranslation} from '@payloadcms/ui/providers/Translation'\n//import {translations} from '../../translations.js'\n\nexport const _LoginButton: CustomComponent = ({internalProviderName, externalProviderName}: {\n internalProviderName: string,\n externalProviderName: string\n}) => {\n //currently not working\n //const {t} = useTranslation<typeof translations.en, NestedKeysStripped<typeof translations.en>>()\n\n return (\n <div style={{display: 'flex', justifyContent: 'center'}}>\n <Button onClick={() => signIn(internalProviderName)}>\n {/*t('zitadelPlugin:signIn', {externalProviderName})*/}\n {externalProviderName}\n </Button>\n </div>\n )\n}"],"names":["React","signIn","Button","_LoginButton","internalProviderName","externalProviderName","div","style","display","justifyContent","onClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,OAAOA,WAAW,QAAO;AACzB,SAAQC,MAAM,QAAO,kBAAiB;AAEtC,6DAA6D;AAC7D,SAAQC,MAAM,QAAO,wBAAuB;AAC5C,qEAAqE;AACrE,oDAAoD;AAEpD,OAAO,MAAMC,eAAgC,CAAC,EAACC,oBAAoB,EAAEC,oBAAoB,EAGxF;IACG,uBAAuB;IACvB,kGAAkG;IAElG,qBACI,oBAACC;QAAIC,OAAO;YAACC,SAAS;YAAQC,gBAAgB;QAAQ;qBAClD,oBAACP;QAAOQ,SAAS,IAAMT,OAAOG;OAEzBC;AAIjB,EAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LoginButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,eAAO,MAAM,WAAW,mDAAkD;IACtE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAA;CAC/B,4BAAkH,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LoginButton/index.tsx"],"sourcesContent":["import React from 'react'\nimport {_LoginButton} from './button.js'\n\nexport const LoginButton = ({internalProviderName, externalProviderName}: {\n internalProviderName: string,\n externalProviderName: string\n}) => () => <_LoginButton internalProviderName={internalProviderName} externalProviderName={externalProviderName}/>"],"names":["React","_LoginButton","LoginButton","internalProviderName","externalProviderName"],"rangeMappings":";;;;;","mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,SAAQC,YAAY,QAAO,cAAa;AAExC,OAAO,MAAMC,cAAc,CAAC,EAACC,oBAAoB,EAAEC,oBAAoB,EAGtE,GAAK,kBAAM,oBAACH;YAAaE,sBAAsBA;YAAsBC,sBAAsBA;WAAuB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Session/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAA;AAGvC,eAAO,MAAM,OAAO,iBAAgB,iBAAiB,sBAAkD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Session/index.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport {SessionProvider} from 'next-auth/react'\nimport {PropsWithChildren} from 'react'\n\n\nexport const Session = ({children}: PropsWithChildren) => <SessionProvider>{children}</SessionProvider>"],"names":["React","SessionProvider","Session","children"],"rangeMappings":";;;","mappings":"AAAA;AAEA,YAAYA,WAAW,QAAO;AAC9B,SAAQC,eAAe,QAAO,kBAAiB;AAI/C,OAAO,MAAMC,UAAU,CAAC,EAACC,QAAQ,EAAoB,iBAAK,oBAACF,uBAAiBE,UAA2B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["//export {Avatar} from './Avatar/index.js'\nexport {LoginButton} from './LoginButton/index.js'\nexport {Session} from './Session/index.js'"],"names":["LoginButton","Session"],"rangeMappings":";;","mappings":"AAAA,0CAA0C;AAC1C,SAAQA,WAAW,QAAO,yBAAwB;AAClD,SAAQC,OAAO,QAAO,qBAAoB"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,yBAAyB,EAAC,MAAM,YAAY,CAAA;AAI7E,eAAO,MAAM,qBAAqB,EAAE,yBAqKnC,CAAA"}
|
package/dist/index.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import NextAuth from 'next-auth';
|
1
|
+
import NextAuth, { getServerSession } from 'next-auth';
|
2
2
|
import { signOut } from 'next-auth/react';
|
3
|
-
import { LoginButton } from './LoginButton/index.js';
|
4
3
|
import { authOptions } from './options.js';
|
5
4
|
import { zitadelStrategy } from './strategy.js';
|
6
5
|
import { translations } from './translations.js';
|
7
|
-
|
8
|
-
export const ZitadelPluginProvider = ({ authSlug = 'users', associatedIdFieldName = 'idp_id',
|
6
|
+
import { LoginButton, Session } from './components/index.js';
|
7
|
+
export const ZitadelPluginProvider = ({ authSlug = 'users', associatedIdFieldName = 'idp_id', //disableAvatar,
|
8
|
+
disableLocalStrategy, disableDefaultLoginButton, internalProviderName = 'zitadel', externalProviderName = 'ZITADEL', issuerUrl, clientId, enableAPI, apiClientId, apiKeyId, apiKey })=>{
|
9
9
|
if ((issuerUrl ?? '').length == 0) throw new Error('ZITADEL-PLUGIN: ISSUER-URL IS EMPTY');
|
10
10
|
if ((clientId ?? '').length == 0) throw new Error('ZITADEL-PLUGIN: CLIENT-ID IS EMPTY');
|
11
11
|
if (enableAPI) {
|
@@ -23,6 +23,8 @@ export const ZitadelPluginProvider = ({ authSlug = 'users', associatedIdFieldNam
|
|
23
23
|
...incomingConfig,
|
24
24
|
admin: {
|
25
25
|
...incomingConfig.admin,
|
26
|
+
// currently not working
|
27
|
+
//...(disableAvatar ? {} : {avatar: Avatar}),
|
26
28
|
components: {
|
27
29
|
...incomingConfig.admin?.components,
|
28
30
|
afterLogin: [
|
@@ -33,6 +35,9 @@ export const ZitadelPluginProvider = ({ authSlug = 'users', associatedIdFieldNam
|
|
33
35
|
externalProviderName
|
34
36
|
})
|
35
37
|
]
|
38
|
+
],
|
39
|
+
providers: [
|
40
|
+
Session
|
36
41
|
]
|
37
42
|
}
|
38
43
|
},
|
@@ -66,6 +71,32 @@ export const ZitadelPluginProvider = ({ authSlug = 'users', associatedIdFieldNam
|
|
66
71
|
type: 'text',
|
67
72
|
unique: true,
|
68
73
|
required: true
|
74
|
+
},
|
75
|
+
{
|
76
|
+
name: 'email',
|
77
|
+
type: 'email',
|
78
|
+
admin: {
|
79
|
+
readOnly: true
|
80
|
+
},
|
81
|
+
access: {},
|
82
|
+
hooks: {
|
83
|
+
afterRead: [
|
84
|
+
async ()=>(await getServerSession())?.user?.email
|
85
|
+
]
|
86
|
+
}
|
87
|
+
},
|
88
|
+
{
|
89
|
+
name: 'name',
|
90
|
+
type: 'text',
|
91
|
+
admin: {
|
92
|
+
readOnly: true
|
93
|
+
},
|
94
|
+
access: {},
|
95
|
+
hooks: {
|
96
|
+
afterRead: [
|
97
|
+
async ()=>(await getServerSession())?.user?.name
|
98
|
+
]
|
99
|
+
}
|
69
100
|
}
|
70
101
|
],
|
71
102
|
hooks: {
|
@@ -105,12 +136,13 @@ export const ZitadelPluginProvider = ({ authSlug = 'users', associatedIdFieldNam
|
|
105
136
|
i18n: {
|
106
137
|
...incomingConfig.i18n,
|
107
138
|
translations: {
|
139
|
+
...incomingConfig.i18n?.translations,
|
108
140
|
de: {
|
109
|
-
...incomingConfig.i18n?.translations?.de
|
141
|
+
...incomingConfig.i18n?.translations?.de,
|
110
142
|
...translations.de
|
111
143
|
},
|
112
144
|
en: {
|
113
|
-
...incomingConfig.i18n?.translations?.en
|
145
|
+
...incomingConfig.i18n?.translations?.en,
|
114
146
|
...translations.en
|
115
147
|
}
|
116
148
|
}
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import NextAuth from 'next-auth'\nimport {signOut} from 'next-auth/react'\nimport {LoginButton} from './LoginButton/index.js'\nimport {authOptions} from './options.js'\nimport {zitadelStrategy} from './strategy.js'\nimport {ZitadelAuthOptionsProps, ZitadelPluginProviderType} from './types.js'\nimport {translations} from './translations.js'\n\n\nexport {LoginButton}\n\nexport const ZitadelPluginProvider: ZitadelPluginProviderType = ({\n authSlug = 'users',\n associatedIdFieldName = 'idp_id',\n disableLocalStrategy,\n disableDefaultLoginButton,\n internalProviderName = 'zitadel',\n externalProviderName = 'ZITADEL',\n issuerUrl,\n clientId,\n enableAPI,\n apiClientId,\n apiKeyId,\n apiKey\n }) => {\n if ((issuerUrl ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: ISSUER-URL IS EMPTY')\n if ((clientId ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: CLIENT-ID IS EMPTY')\n if (enableAPI) {\n if ((apiClientId ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: API ENABLED, BUT API-CLIENT-ID IS EMPTY')\n if ((apiKeyId ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: API ENABLED, BUT API-KEY-ID IS EMPTY')\n if ((apiKey ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: API ENABLED, BUT API-KEY IS EMPTY')\n }\n const authOptionsProps: ZitadelAuthOptionsProps = {\n internalProviderName: internalProviderName,\n issuerUrl: issuerUrl!,\n clientId: clientId!\n }\n return {\n zitadelPlugin: (incomingConfig) => ({\n ...incomingConfig,\n admin: {\n ...incomingConfig.admin,\n components: {\n ...incomingConfig.admin?.components,\n afterLogin: [\n ...incomingConfig.admin?.components?.afterLogin || [],\n ...(disableDefaultLoginButton ? [] : [LoginButton({\n internalProviderName,\n externalProviderName\n })])\n ]\n }\n },\n collections: (incomingConfig.collections || []).map((collection) => ({\n ...collection,\n ...collection.slug == authSlug ? {\n auth: {\n ...(typeof collection.auth == 'boolean' ? {} : collection.auth),\n disableLocalStrategy: disableLocalStrategy ? disableLocalStrategy : (typeof collection.auth == 'boolean' ? {} : collection.auth)?.disableLocalStrategy,\n strategies: [\n ...(typeof collection.auth == 'boolean' ? {} : collection.auth)?.strategies ?? [],\n zitadelStrategy({\n authSlug,\n associatedIdFieldName,\n ...authOptionsProps,\n ...(enableAPI ? {\n enableAPI: true,\n apiClientId: apiClientId!,\n apiKeyId: apiClientId!,\n apiKey: apiKey!\n } : {enableAPI: undefined})\n })\n ]\n },\n fields: [\n ...collection.fields,\n {\n name: associatedIdFieldName,\n type: 'text',\n unique: true,\n required: true\n }\n ],\n hooks: {\n afterLogout: [\n () => signOut()\n ]\n }\n } : {}\n })),\n //would be a more developer-friendly alternative\n //currently not working, maybe in future update\n /*endpoints: [\n ...incomingConfig.endpoints || [],\n ...['get', 'post'].map(method => ({\n handler: NextAuth.default(authOptions(authOptionsProps)),\n method: method as 'get' | 'post',\n path: 'api/auth/*'\n }))\n ],*/\n\n //current work around on creating a non-functional first user\n async onInit(payload) {\n if (incomingConfig.onInit)\n await incomingConfig.onInit(payload)\n\n const existingUsers = await payload.find({\n collection: authSlug,\n limit: 1\n })\n\n if (existingUsers.docs.length === 0) {\n await payload.create({\n collection: authSlug,\n data: {\n email: 'delete.me@now.com',\n password: 'password',\n [associatedIdFieldName]: 'DELETE_ME'\n }\n })\n }\n },\n i18n: {\n ...incomingConfig.i18n,\n translations: {\n de: {\n ...incomingConfig.i18n?.translations?.de ?? {},\n ...translations.de\n },\n en: {\n ...incomingConfig.i18n?.translations?.en ?? {},\n ...translations.en\n }\n }\n }\n }),\n nextauthHandler: NextAuth.default(authOptions(authOptionsProps))\n }\n}"],"names":["NextAuth","signOut","LoginButton","authOptions","zitadelStrategy","translations","ZitadelPluginProvider","authSlug","associatedIdFieldName","disableLocalStrategy","disableDefaultLoginButton","internalProviderName","externalProviderName","issuerUrl","clientId","enableAPI","apiClientId","apiKeyId","apiKey","length","Error","authOptionsProps","zitadelPlugin","incomingConfig","admin","components","afterLogin","collections","map","collection","slug","auth","strategies","undefined","fields","name","type","unique","required","hooks","afterLogout","onInit","payload","existingUsers","find","limit","docs","create","data","email","password","i18n","de","en","nextauthHandler","default"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,cAAc,YAAW;AAChC,SAAQC,OAAO,QAAO,kBAAiB;AACvC,SAAQC,WAAW,QAAO,yBAAwB;AAClD,SAAQC,WAAW,QAAO,eAAc;AACxC,SAAQC,eAAe,QAAO,gBAAe;AAE7C,SAAQC,YAAY,QAAO,oBAAmB;AAG9C,SAAQH,WAAW,GAAC;AAEpB,OAAO,MAAMI,wBAAmD,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E9C,cAAc+C,MAAM,CAAC,CAAC;4BAC9C,GAAG/C,aAAa+C,EAAE;wBACtB;wBACAC,IAAI;4BACA,GAAG9B,eAAe4B,IAAI,EAAE9C,cAAcgD,MAAM,CAAC,CAAC;4BAC9C,GAAGhD,aAAagD,EAAE;wBACtB;oBACJ;gBACJ;YACJ,CAAA;QACAC,iBAAiBtD,SAASuD,OAAO,CAACpD,YAAYkB;IAClD;AACJ,EAAC"}
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import NextAuth, {getServerSession} from 'next-auth'\nimport {signOut} from 'next-auth/react'\nimport {authOptions} from './options.js'\nimport {zitadelStrategy} from './strategy.js'\nimport {ZitadelAuthOptionsProps, ZitadelPluginProviderType} from './types.js'\nimport {translations} from './translations.js'\nimport {LoginButton, Session} from './components/index.js'\n\nexport const ZitadelPluginProvider: ZitadelPluginProviderType = ({\n authSlug = 'users',\n associatedIdFieldName = 'idp_id',\n //disableAvatar,\n disableLocalStrategy,\n disableDefaultLoginButton,\n internalProviderName = 'zitadel',\n externalProviderName = 'ZITADEL',\n issuerUrl,\n clientId,\n enableAPI,\n apiClientId,\n apiKeyId,\n apiKey\n }) => {\n if ((issuerUrl ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: ISSUER-URL IS EMPTY')\n if ((clientId ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: CLIENT-ID IS EMPTY')\n if (enableAPI) {\n if ((apiClientId ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: API ENABLED, BUT API-CLIENT-ID IS EMPTY')\n if ((apiKeyId ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: API ENABLED, BUT API-KEY-ID IS EMPTY')\n if ((apiKey ?? '').length == 0)\n throw new Error('ZITADEL-PLUGIN: API ENABLED, BUT API-KEY IS EMPTY')\n }\n const authOptionsProps: ZitadelAuthOptionsProps = {\n internalProviderName: internalProviderName,\n issuerUrl: issuerUrl!,\n clientId: clientId!\n }\n return {\n zitadelPlugin: (incomingConfig) => ({\n ...incomingConfig,\n admin: {\n ...incomingConfig.admin,\n // currently not working\n //...(disableAvatar ? {} : {avatar: Avatar}),\n components: {\n ...incomingConfig.admin?.components,\n afterLogin: [\n ...incomingConfig.admin?.components?.afterLogin || [],\n ...(disableDefaultLoginButton ? [] : [LoginButton({\n internalProviderName,\n externalProviderName\n })])\n ],\n providers: [\n Session\n ]\n }\n },\n collections: (incomingConfig.collections || []).map((collection) => ({\n ...collection,\n ...collection.slug == authSlug ? {\n auth: {\n ...(typeof collection.auth == 'boolean' ? {} : collection.auth),\n disableLocalStrategy: disableLocalStrategy ? disableLocalStrategy : (typeof collection.auth == 'boolean' ? {} : collection.auth)?.disableLocalStrategy,\n strategies: [\n ...(typeof collection.auth == 'boolean' ? {} : collection.auth)?.strategies ?? [],\n zitadelStrategy({\n authSlug,\n associatedIdFieldName,\n ...authOptionsProps,\n ...(enableAPI ? {\n enableAPI: true,\n apiClientId: apiClientId!,\n apiKeyId: apiClientId!,\n apiKey: apiKey!\n } : {enableAPI: undefined})\n })\n ]\n },\n fields: [\n ...collection.fields,\n {\n name: associatedIdFieldName,\n type: 'text',\n unique: true,\n required: true\n },\n {\n name: 'email',\n type: 'email',\n admin: {\n readOnly: true\n },\n access: {},\n hooks: {\n afterRead: [\n async () => (await getServerSession())?.user?.email\n ]\n }\n },\n {\n name: 'name',\n type: 'text',\n admin: {\n readOnly: true\n },\n access: {},\n hooks: {\n afterRead: [\n async () => (await getServerSession())?.user?.name\n ]\n }\n }\n ],\n hooks: {\n afterLogout: [\n () => signOut()\n ]\n }\n } : {}\n })),\n //would be a more developer-friendly alternative\n //currently not working, maybe in future update\n /*endpoints: [\n ...incomingConfig.endpoints || [],\n ...['get', 'post'].map(method => ({\n handler: NextAuth.default(authOptions(authOptionsProps)),\n method: method as 'get' | 'post',\n path: 'api/auth/*'\n }))\n ],*/\n\n //current work around on creating a non-functional first user\n async onInit(payload) {\n if (incomingConfig.onInit)\n await incomingConfig.onInit(payload)\n\n const existingUsers = await payload.find({\n collection: authSlug,\n limit: 1\n })\n\n if (existingUsers.docs.length === 0) {\n await payload.create({\n collection: authSlug,\n data: {\n email: 'delete.me@now.com',\n password: 'password',\n [associatedIdFieldName]: 'DELETE_ME'\n }\n })\n }\n },\n i18n: {\n ...incomingConfig.i18n,\n translations: {\n ...incomingConfig.i18n?.translations,\n de: {\n ...incomingConfig.i18n?.translations?.de,\n ...translations.de\n },\n en: {\n ...incomingConfig.i18n?.translations?.en,\n ...translations.en\n }\n }\n }\n }),\n nextauthHandler: NextAuth.default(authOptions(authOptionsProps))\n }\n}"],"names":["NextAuth","getServerSession","signOut","authOptions","zitadelStrategy","translations","LoginButton","Session","ZitadelPluginProvider","authSlug","associatedIdFieldName","disableLocalStrategy","disableDefaultLoginButton","internalProviderName","externalProviderName","issuerUrl","clientId","enableAPI","apiClientId","apiKeyId","apiKey","length","Error","authOptionsProps","zitadelPlugin","incomingConfig","admin","components","afterLogin","providers","collections","map","collection","slug","auth","strategies","undefined","fields","name","type","unique","required","readOnly","access","hooks","afterRead","user","email","afterLogout","onInit","payload","existingUsers","find","limit","docs","create","data","password","i18n","de","en","nextauthHandler","default"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAWC,gBAAgB,QAAO,YAAW;AACpD,SAAQC,OAAO,QAAO,kBAAiB;AACvC,SAAQC,WAAW,QAAO,eAAc;AACxC,SAAQC,eAAe,QAAO,gBAAe;AAE7C,SAAQC,YAAY,QAAO,oBAAmB;AAC9C,SAAQC,WAAW,EAAEC,OAAO,QAAO,wBAAuB;AAE1D,OAAO,MAAMC,wBAAmD,CAAC,EACIC,WAAW,OAAO,EAClBC,wBAAwB,QAAQ,EAChC,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MAAMC,gBAAgB,MAAMD,QAAQE,IAAI,CAAC;wBACrCpB,YAAYvB;wBACZ4C,OAAO;oBACX;oBAEA,IAAIF,cAAcG,IAAI,CAACjC,MAAM,KAAK,GAAG;wBACjC,MAAM6B,QAAQK,MAAM,CAAC;4BACjBvB,YAAYvB;4BACZ+C,MAAM;gCACFT,OAAO;gCACPU,UAAU;gCACV,CAAC/C,sBAAsB,EAAE;4BAC7B;wBACJ;oBACJ;gBACJ;gBACAgD,MAAM;oBACF,GAAGjC,eAAeiC,IAAI;oBACtBrD,cAAc;wBACV,GAAGoB,eAAeiC,IAAI,EAAErD,YAAY;wBACpCsD,IAAI;4BACA,GAAGlC,eAAeiC,IAAI,EAAErD,cAAcsD,EAAE;4BACxC,GAAGtD,aAAasD,EAAE;wBACtB;wBACAC,IAAI;4BACA,GAAGnC,eAAeiC,IAAI,EAAErD,cAAcuD,EAAE;4BACxC,GAAGvD,aAAauD,EAAE;wBACtB;oBACJ;gBACJ;YACJ,CAAA;QACAC,iBAAiB7D,SAAS8D,OAAO,CAAC3D,YAAYoB;IAClD;AACJ,EAAC"}
|
package/dist/types.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import { NextAuthOptions } from 'next-auth';
|
2
|
-
import { AuthStrategy } from 'payload
|
3
|
-
import { Config } from 'payload
|
2
|
+
import { AuthStrategy } from 'payload';
|
3
|
+
import { Config } from 'payload';
|
4
4
|
export type ZitadelPluginProps = {
|
5
|
+
disableAvatar?: true | undefined;
|
5
6
|
disableLocalStrategy?: true | undefined;
|
6
7
|
disableDefaultLoginButton?: true | undefined;
|
7
8
|
defaultLoginButtonTitle?: string;
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,WAAW,CAAA;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,
|
1
|
+
{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CACxB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;AAE7B,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,oBAAoB,KAAK,YAAY,CAAA"}
|
package/dist/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import {NextAuthOptions} from 'next-auth'\nimport {AuthStrategy} from 'payload
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import {NextAuthOptions} from 'next-auth'\nimport {AuthStrategy} from 'payload'\nimport {Config} from 'payload'\n\nexport type ZitadelPluginProps = {\n disableAvatar?: true | undefined\n disableLocalStrategy?: true | undefined\n disableDefaultLoginButton?: true | undefined\n defaultLoginButtonTitle?: string\n externalProviderName?: string\n} & Partial<ZitadelStrategyProps>\n\nexport type ZitadelPluginProviderType = (props: ZitadelPluginProps) => {\n zitadelPlugin: (incomingConfig: Config) => Config,\n nextauthHandler: any\n}\n\nexport type ZitadelAuthOptionsProps = {\n internalProviderName: string,\n issuerUrl: string,\n clientId: string\n}\n\nexport type ZitadelAuthOptionsType = (props: ZitadelAuthOptionsProps) => NextAuthOptions\n\nexport type ZitadelAPIProps = {\n enableAPI: true\n apiClientId: string,\n apiKeyId: string,\n apiKey: string\n}\n\nexport type ZitadelStrategyProps = ZitadelAuthOptionsProps & {\n authSlug: string,\n associatedIdFieldName: string,\n} & (ZitadelAPIProps | {\n enableAPI?: undefined\n} & Partial<ZitadelAPIProps>)\n\nexport type ZitadelStrategyType = (props: ZitadelStrategyProps) => AuthStrategy"],"names":[],"rangeMappings":"","mappings":"AAuCA,WAA+E"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "payload-zitadel-plugin",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.4",
|
4
4
|
"description": "plugin for Payload CMS, which enables authentication via Zitadel IdP",
|
5
5
|
"type": "module",
|
6
6
|
"license": "MIT",
|
@@ -36,24 +36,24 @@
|
|
36
36
|
"dist"
|
37
37
|
],
|
38
38
|
"dependencies": {
|
39
|
-
"@payloadcms/translations": "3.0.0-beta.
|
40
|
-
"@payloadcms/ui": "3.0.0-beta.
|
39
|
+
"@payloadcms/translations": "3.0.0-beta.52",
|
40
|
+
"@payloadcms/ui": "3.0.0-beta.52",
|
41
41
|
"jsonwebtoken": "^9.0.2",
|
42
42
|
"next": "^15.0.0-rc.0",
|
43
43
|
"next-auth": "^4.24.7",
|
44
|
-
"payload": "3.0.0-beta.
|
45
|
-
"react": "
|
46
|
-
"react-dom": "
|
44
|
+
"payload": "3.0.0-beta.52",
|
45
|
+
"react": "rc",
|
46
|
+
"react-dom": "rc"
|
47
47
|
},
|
48
48
|
"devDependencies": {
|
49
49
|
"@swc/cli": "^0.3.12",
|
50
50
|
"@swc/core": "^1.6.1",
|
51
51
|
"@types/jsonwebtoken": "^9.0.6",
|
52
|
-
"@types/node": "^20.14.
|
52
|
+
"@types/node": "^20.14.5",
|
53
53
|
"@types/react": "^18.3.3",
|
54
54
|
"@types/react-dom": "^18.3.0",
|
55
55
|
"rimraf": "^5.0.7",
|
56
|
-
"typescript": "^5.6.0-dev.
|
56
|
+
"typescript": "^5.6.0-dev.20240618"
|
57
57
|
},
|
58
58
|
"engines": {
|
59
59
|
"node": "^22.3.0"
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/LoginButton/button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAA;AAM9C,eAAO,MAAM,YAAY,EAAE,eAa1B,CAAA"}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
'use client';
|
2
|
-
import React from 'react';
|
3
|
-
import { signIn } from 'next-auth/react';
|
4
|
-
import { Button } from '@payloadcms/ui/elements';
|
5
|
-
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
6
|
-
export const _LoginButton = ({ internalProviderName, externalProviderName })=>{
|
7
|
-
const { t } = useTranslation();
|
8
|
-
return /*#__PURE__*/ React.createElement("div", {
|
9
|
-
style: {
|
10
|
-
display: 'flex',
|
11
|
-
justifyContent: 'center'
|
12
|
-
}
|
13
|
-
}, /*#__PURE__*/ React.createElement(Button, {
|
14
|
-
onClick: ()=>signIn(internalProviderName)
|
15
|
-
}, t('zitadelPlugin:signIn', {
|
16
|
-
externalProviderName
|
17
|
-
})));
|
18
|
-
};
|
19
|
-
|
20
|
-
//# sourceMappingURL=button.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/LoginButton/button.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\nimport {signIn} from 'next-auth/react'\nimport {CustomComponent} from 'payload/config'\nimport {NestedKeysStripped} from '@payloadcms/translations'\nimport {Button} from '@payloadcms/ui/elements'\nimport {useTranslation} from '@payloadcms/ui/providers/Translation'\nimport {translations} from '../translations.js'\n\nexport const _LoginButton: CustomComponent = ({internalProviderName, externalProviderName}: {\n internalProviderName: string,\n externalProviderName: string\n}) => {\n const {t} = useTranslation<typeof translations.en, NestedKeysStripped<typeof translations.en>>()\n\n return (\n <div style={{display: 'flex', justifyContent: 'center'}}>\n <Button onClick={() => signIn(internalProviderName)}>\n {t('zitadelPlugin:signIn', {externalProviderName})}\n </Button>\n </div>\n )\n}"],"names":["React","signIn","Button","useTranslation","_LoginButton","internalProviderName","externalProviderName","t","div","style","display","justifyContent","onClick"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,OAAOA,WAAW,QAAO;AACzB,SAAQC,MAAM,QAAO,kBAAiB;AAGtC,SAAQC,MAAM,QAAO,0BAAyB;AAC9C,SAAQC,cAAc,QAAO,uCAAsC;AAGnE,OAAO,MAAMC,eAAgC,CAAC,EAACC,oBAAoB,EAAEC,oBAAoB,EAGxF;IACG,MAAM,EAACC,CAAC,EAAC,GAAGJ;IAEZ,qBACI,oBAACK;QAAIC,OAAO;YAACC,SAAS;YAAQC,gBAAgB;QAAQ;qBAClD,oBAACT;QAAOU,SAAS,IAAMX,OAAOI;OACzBE,EAAE,wBAAwB;QAACD;IAAoB;AAIhE,EAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/LoginButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,eAAO,MAAM,WAAW,mDAAkD;IACtE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAA;CAC/B,4BAAkH,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/LoginButton/index.tsx"],"sourcesContent":["import React from 'react'\nimport {_LoginButton} from './button.js'\n\nexport const LoginButton = ({internalProviderName, externalProviderName}: {\n internalProviderName: string,\n externalProviderName: string\n}) => () => <_LoginButton internalProviderName={internalProviderName} externalProviderName={externalProviderName}/>"],"names":["React","_LoginButton","LoginButton","internalProviderName","externalProviderName"],"rangeMappings":";;;;;","mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,SAAQC,YAAY,QAAO,cAAa;AAExC,OAAO,MAAMC,cAAc,CAAC,EAACC,oBAAoB,EAAEC,oBAAoB,EAGtE,GAAK,kBAAM,oBAACH;YAAaE,sBAAsBA;YAAsBC,sBAAsBA;WAAuB"}
|
File without changes
|
File without changes
|