0.0.32 • Published 17 hours ago

@newesissrl/payload-zitadel-plugin v0.0.32

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
17 hours ago

payload-zitadel-plugin

Extends payloadcms with Zitadel integration

Install

yarn add @newesissrl/payload-zitadel-plugin yarn add cookie-parser

Get Started

server.ts

const cookieParser = require("cookie-parser");
import { ZitadelRoutes } from "@newesissrl/payload-zitadel-plugin/dist/routes";
....
app.use(cookieParser());
....
await payload.init(....);
ZitadelRoutes(app);
....

PAYLOAD_PUBLIC env variables

PAYLOAD_PUBLIC_ZITADEL_REDIRECT_URI=http://localhost:3030/zitadel/redirect
PAYLOAD_PUBLIC_ZITADEL_TOKEN_ENDPOINT=http://localhost:8080/oauth/v2/token
PAYLOAD_PUBLIC_ZITADEL_USER_INFO=http://localhost:8080/oidc/v1/userinfo
PAYLOAD_PUBLIC_ZITADEL_AUTHORIZE_ENDPOINT=http://localhost:8080/oauth/v2/authorize
PAYLOAD_PUBLIC_ZITADEL_CLIENT_ID= #the one you get from Zitadel app
PAYLOAD_PUBLIC_ZITADEL_COOKIE_NAME= #(optional) if you want to specify a different cookie name
PAYLOAD_PUBLIC_ZITADEL_COOKIE_SECURE= #(optional) if you want to specify a secure cookie (default = false)
PAYLOAD_PUBLIC_ZITADEL_COOKIE_SAMESITE= #(optional) if you want to specify a different sameSite option for cookie. default = "lax"
PAYLOAD_PUBLIC_COOKIE_DOMAIN= #(optional) if you want to specify a cookie domain

payload.config.ts

import { ZitadelStrategyPlugin } from "@newesissrl/payload-zitadel-plugin/dist/plugins";
import { LoginButton } from "@newesissrl/payload-zitadel-plugin/dist/components/LoginButton";

const buildConfigAsync = async () => {
    const zitadelPlugin = await ZitadelStrategyPlugin({
      ui: {
        beforeOrAfterLogin? // where to place the button (before|after, default = "after")
        loginButtonLabel? // the label to use for the login button (default = "login-with-zitadel")
        LoginButton: LoginButton // the component to use for the login button
      },
      auth: {
        authorizeEndpoint: process.env.PAYLOAD_PUBLIC_ZITADEL_AUTHORIZE_ENDPOINT,
        clientID: process.env.PAYLOAD_PUBLIC_ZITADEL_CLIENT_ID,
        redirectUri: process.env.PAYLOAD_PUBLIC_ZITADEL_REDIRECT_URI,
      },
      fieldsMappings: [], // useful to remap fields from idP to the desired `required` fields
      /*
      [{
        from: "name",
        to: "first_name"
      },
      ...]
      */
     loggerOptions? // optional logging options for `pino` library
    });
    return buildConfig({
      .....
      plugins: [...., zitadelPlugin],
    })
}

Notes

If you want to override the LoginButton component, your React component must accept those properties:

loginButtonLabel,
codeChallenge,
authorizeEndpoint,
redirectUri,
clientID,
scope,
codeChallengeMethod,
state
0.0.31

20 hours ago

0.0.32

17 hours ago

0.0.30

8 days ago

0.0.28

2 months ago

0.0.26

2 months ago

0.0.25

3 months ago

0.0.24

3 months ago

0.0.23

4 months ago

0.0.22

4 months ago

0.0.20

4 months ago

0.0.21

4 months ago

0.0.17

4 months ago

0.0.18

4 months ago

0.0.19

4 months ago

0.0.16

4 months ago

0.0.14

4 months ago

0.0.15

4 months ago

0.0.13

4 months ago

0.0.10

4 months ago

0.0.11

4 months ago

0.0.12

4 months ago

0.0.9

4 months ago

0.0.8

4 months ago

0.0.7

4 months ago

0.0.6

4 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago