payload-zitadel-plugin 0.2.31 → 0.2.33
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 +2 -2
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +2 -3
- package/dist/components/Avatar.js.map +1 -1
- package/dist/handlers/callback.d.ts.map +1 -1
- package/dist/handlers/callback.js +0 -1
- package/dist/handlers/callback.js.map +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
plugin for [Payload CMS](https://payloadcms.com), which enables authentication via Zitadel IdP.
|
6
6
|
|
7
7
|
The default use case is to fully replace PayloadCMS Auth with Zitadel.
|
8
|
-
Thus the user collection in PayloadCMS becomes just a shadow of the information in Zitadel.
|
8
|
+
Thus, the user collection in PayloadCMS becomes just a shadow of the information in Zitadel.
|
9
9
|
|
10
10
|
:boom: :boom: :boom: works :100: with PayloadCMS version :three: :boom: :boom: :boom:
|
11
11
|
|
12
12
|
## Install
|
13
13
|
|
14
14
|
```shell
|
15
|
-
pnpm add payload-zitadel-plugin@0.2.
|
15
|
+
pnpm add payload-zitadel-plugin@0.2.33
|
16
16
|
```
|
17
17
|
|
18
18
|
## Configuration
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../src/components/Avatar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,eAAO,MAAM,MAAM,eAAc;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../src/components/Avatar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,eAAO,MAAM,MAAM,eAAc;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,sBAgBnD,CAAA"}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
'use client';
|
2
2
|
import * as React from 'react';
|
3
3
|
import { DefaultAccountIcon } from '@payloadcms/ui/graphics/Account/Default';
|
4
|
-
import {
|
4
|
+
import { useAuth } from '@payloadcms/ui';
|
5
5
|
export const Avatar = ({ active })=>{
|
6
|
-
const {
|
7
|
-
const { user } = data;
|
6
|
+
const { user } = useAuth();
|
8
7
|
return user?.image ? /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("style", null, 'zitadel-avatar:hover { filter: brightness(1.2); }'), /*#__PURE__*/ React.createElement("img", {
|
9
8
|
className: "zitadel-avatar",
|
10
9
|
src: user.image,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/components/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport {DefaultAccountIcon} from '@payloadcms/ui/graphics/Account/Default'\nimport {
|
1
|
+
{"version":3,"sources":["../../src/components/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport {DefaultAccountIcon} from '@payloadcms/ui/graphics/Account/Default'\nimport {useAuth} from '@payloadcms/ui'\nimport {ZitadelUser} from '../types.js'\n\nexport const Avatar = ({active}: { active: boolean }) => {\n\n const {user} = useAuth<ZitadelUser>()\n\n return (\n user?.image ?\n <>\n <style>{'zitadel-avatar:hover { filter: brightness(1.2); }'}</style>\n <img className=\"zitadel-avatar\" src={user.image} height={25} width={25} alt=\"Profile Picture\" style={{\n borderRadius: '100%',\n ...(active ? {filter: 'brightness(.8)'} : {})\n }}/>\n </> :\n <DefaultAccountIcon active={active}/>\n )\n\n}\n"],"names":["React","DefaultAccountIcon","useAuth","Avatar","active","user","image","style","img","className","src","height","width","alt","borderRadius","filter"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAO;AAC9B,SAAQC,kBAAkB,QAAO,0CAAyC;AAC1E,SAAQC,OAAO,QAAO,iBAAgB;AAGtC,OAAO,MAAMC,SAAS,CAAC,EAACC,MAAM,EAAsB;IAEhD,MAAM,EAACC,IAAI,EAAC,GAAGH;IAEf,OACIG,MAAMC,sBACF,wDACI,oBAACC,eAAO,oEACR,oBAACC;QAAIC,WAAU;QAAiBC,KAAKL,KAAKC,KAAK;QAAEK,QAAQ;QAAIC,OAAO;QAAIC,KAAI;QAAkBN,OAAO;YACjGO,cAAc;YACd,GAAIV,SAAS;gBAACW,QAAQ;YAAgB,IAAI,CAAC,CAAC;QAChD;wBAEJ,oBAACd;QAAmBG,QAAQA;;AAGxC,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/handlers/callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAItC,OAAO,EAA2C,gBAAgB,EAAC,MAAM,aAAa,CAAA;AAGtF,eAAO,MAAM,QAAQ,cAAe,gBAAgB,KAAG,
|
1
|
+
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/handlers/callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAItC,OAAO,EAA2C,gBAAgB,EAAC,MAAM,aAAa,CAAA;AAGtF,eAAO,MAAM,QAAQ,cAAe,gBAAgB,KAAG,cAiEtD,CAAA"}
|
@@ -20,7 +20,6 @@ export const callback = (onSuccess)=>async ({ payload: { config, secret }, query
|
|
20
20
|
if (response.ok) {
|
21
21
|
const { id_token } = await response.json();
|
22
22
|
if (id_token) {
|
23
|
-
console.log(JSON.stringify(jwt.decode(id_token)));
|
24
23
|
cookieStore.delete(COOKIES.pkce);
|
25
24
|
cookieStore.set({
|
26
25
|
name: COOKIES.idToken,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/handlers/callback.ts"],"sourcesContent":["import {PayloadHandler} from 'payload'\nimport {cookies} from 'next/headers.js'\nimport process from 'node:process'\nimport jwt from 'jsonwebtoken'\nimport {PayloadConfigWithZitadel, ZitadelIdToken, ZitadelOnSuccess} from '../types.js'\nimport {COOKIES} from '../constants.js'\n\nexport const callback = (onSuccess: ZitadelOnSuccess): PayloadHandler => async ({\n payload: {config, secret},\n query: {code, state}\n }) => {\n\n const {admin: {custom: {zitadel: {issuerURL, clientId, callbackURL}}}} = config as PayloadConfigWithZitadel\n\n const cookieStore = await cookies()\n\n const code_verifier = cookieStore.get(COOKIES.pkce)?.value\n\n if (code_verifier) {\n\n const response = await fetch(new URL(`${issuerURL}/oauth/v2/token`), {\n method: 'POST',\n body: new URLSearchParams({\n grant_type: 'authorization_code',\n code: code as string,\n redirect_uri: callbackURL,\n client_id: clientId,\n code_verifier\n })\n })\n\n if (response.ok) {\n\n const {id_token} = await response.json()\n\n if (id_token) {\n\n
|
1
|
+
{"version":3,"sources":["../../src/handlers/callback.ts"],"sourcesContent":["import {PayloadHandler} from 'payload'\nimport {cookies} from 'next/headers.js'\nimport process from 'node:process'\nimport jwt from 'jsonwebtoken'\nimport {PayloadConfigWithZitadel, ZitadelIdToken, ZitadelOnSuccess} from '../types.js'\nimport {COOKIES} from '../constants.js'\n\nexport const callback = (onSuccess: ZitadelOnSuccess): PayloadHandler => async ({\n payload: {config, secret},\n query: {code, state}\n }) => {\n\n const {admin: {custom: {zitadel: {issuerURL, clientId, callbackURL}}}} = config as PayloadConfigWithZitadel\n\n const cookieStore = await cookies()\n\n const code_verifier = cookieStore.get(COOKIES.pkce)?.value\n\n if (code_verifier) {\n\n const response = await fetch(new URL(`${issuerURL}/oauth/v2/token`), {\n method: 'POST',\n body: new URLSearchParams({\n grant_type: 'authorization_code',\n code: code as string,\n redirect_uri: callbackURL,\n client_id: clientId,\n code_verifier\n })\n })\n\n if (response.ok) {\n\n const {id_token} = await response.json()\n\n if (id_token) {\n\n cookieStore.delete(COOKIES.pkce)\n\n cookieStore.set({\n name: COOKIES.idToken,\n value: jwt.sign(jwt.decode(id_token) as ZitadelIdToken, secret),\n httpOnly: true,\n path: '/',\n sameSite: 'lax',\n maxAge: 900,\n secure: process.env.NODE_ENV == 'production'\n })\n\n return onSuccess(new URLSearchParams(atob(state as string ?? '')))\n\n }\n\n return Response.json({\n status: 'error',\n message: 'token could not be retrieved from the response'\n })\n\n }\n\n return Response.json({\n status: 'error',\n message: 'error while communicating with token endpoint'\n })\n\n }\n\n return Response.json({\n status: 'error',\n message: 'code verifier not found (associated http-only cookie is empty)'\n })\n\n}"],"names":["cookies","process","jwt","COOKIES","callback","onSuccess","payload","config","secret","query","code","state","admin","custom","zitadel","issuerURL","clientId","callbackURL","cookieStore","code_verifier","get","pkce","value","response","fetch","URL","method","body","URLSearchParams","grant_type","redirect_uri","client_id","ok","id_token","json","delete","set","name","idToken","sign","decode","httpOnly","path","sameSite","maxAge","secure","env","NODE_ENV","atob","Response","status","message"],"mappings":"AACA,SAAQA,OAAO,QAAO,kBAAiB;AACvC,OAAOC,aAAa,eAAc;AAClC,OAAOC,SAAS,eAAc;AAE9B,SAAQC,OAAO,QAAO,kBAAiB;AAEvC,OAAO,MAAMC,WAAW,CAACC,YAAgD,OAAO,EACIC,SAAS,EAACC,MAAM,EAAEC,MAAM,EAAC,EACzBC,OAAO,EAACC,IAAI,EAAEC,KAAK,EAAC,EACvB;QAE7E,MAAM,EAACC,OAAO,EAACC,QAAQ,EAACC,SAAS,EAACC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAC,EAAC,EAAC,EAAC,GAAGV;QAEzE,MAAMW,cAAc,MAAMlB;QAE1B,MAAMmB,gBAAgBD,YAAYE,GAAG,CAACjB,QAAQkB,IAAI,GAAGC;QAErD,IAAIH,eAAe;YAEf,MAAMI,WAAW,MAAMC,MAAM,IAAIC,IAAI,GAAGV,UAAU,eAAe,CAAC,GAAG;gBACjEW,QAAQ;gBACRC,MAAM,IAAIC,gBAAgB;oBACtBC,YAAY;oBACZnB,MAAMA;oBACNoB,cAAcb;oBACdc,WAAWf;oBACXG;gBACJ;YACJ;YAEA,IAAII,SAASS,EAAE,EAAE;gBAEb,MAAM,EAACC,QAAQ,EAAC,GAAG,MAAMV,SAASW,IAAI;gBAEtC,IAAID,UAAU;oBAEVf,YAAYiB,MAAM,CAAChC,QAAQkB,IAAI;oBAE/BH,YAAYkB,GAAG,CAAC;wBACZC,MAAMlC,QAAQmC,OAAO;wBACrBhB,OAAOpB,IAAIqC,IAAI,CAACrC,IAAIsC,MAAM,CAACP,WAA6BzB;wBACxDiC,UAAU;wBACVC,MAAM;wBACNC,UAAU;wBACVC,QAAQ;wBACRC,QAAQ5C,QAAQ6C,GAAG,CAACC,QAAQ,IAAI;oBACpC;oBAEA,OAAO1C,UAAU,IAAIuB,gBAAgBoB,KAAKrC,SAAmB;gBAEjE;gBAEA,OAAOsC,SAASf,IAAI,CAAC;oBACjBgB,QAAQ;oBACRC,SAAS;gBACb;YAEJ;YAEA,OAAOF,SAASf,IAAI,CAAC;gBACjBgB,QAAQ;gBACRC,SAAS;YACb;QAEJ;QAEA,OAAOF,SAASf,IAAI,CAAC;YACjBgB,QAAQ;YACRC,SAAS;QACb;IAEJ,EAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "payload-zitadel-plugin",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.33",
|
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/next": "3.0.0-beta.
|
40
|
-
"@payloadcms/translations": "3.0.0-beta.
|
41
|
-
"@payloadcms/ui": "3.0.0-beta.
|
39
|
+
"@payloadcms/next": "3.0.0-beta.111",
|
40
|
+
"@payloadcms/translations": "3.0.0-beta.111",
|
41
|
+
"@payloadcms/ui": "3.0.0-beta.111",
|
42
42
|
"jsonwebtoken": "^9.0.2",
|
43
|
-
"next": "15.0.0-canary.
|
44
|
-
"payload": "3.0.0-beta.
|
45
|
-
"react": "19.0.0-rc-
|
46
|
-
"react-dom": "19.0.0-rc-
|
43
|
+
"next": "15.0.0-canary.179",
|
44
|
+
"payload": "3.0.0-beta.111",
|
45
|
+
"react": "19.0.0-rc-1460d67c-20241003",
|
46
|
+
"react-dom": "19.0.0-rc-1460d67c-20241003"
|
47
47
|
},
|
48
48
|
"devDependencies": {
|
49
49
|
"@swc/cli": "^0.4.1-nightly.20240914",
|
50
|
-
"@swc/core": "^1.7.
|
50
|
+
"@swc/core": "^1.7.30-nightly-20241002.1",
|
51
51
|
"@types/jsonwebtoken": "^9.0.7",
|
52
52
|
"@types/node": "^22.7.4",
|
53
|
-
"@types/react": "^18.3.
|
53
|
+
"@types/react": "^18.3.11",
|
54
54
|
"@types/react-dom": "^18.3.0",
|
55
55
|
"rimraf": "^6.0.1",
|
56
|
-
"typescript": "5.7.0-dev.
|
56
|
+
"typescript": "5.7.0-dev.20241005"
|
57
57
|
},
|
58
58
|
"engines": {
|
59
59
|
"node": "^22.9.0"
|