gngz

password policy

by gngz
payload-kit
Authentication & SSO
v3
^3.0.0
^3.0.0 · prerelease
MIT

Overview

Summary generated from the README

Enforces composable password rules on Payload auth collections through a beforeValidate hook and a password field validator. It covers create, update and resetPassword, and all checks run offline. Requires Payload 3 and is configured by registering the plugin in the Payload config.

Features

  • Length, lowercase, uppercase, number and special character requirements
  • Rejects common passwords including leetspeak variants
  • Detects repeated runs, sequences, keyboard runs and repeated blocks
  • Rejects passwords containing the user's name, email local part or username
  • Custom rules via extraRules or a full replacement ruleset
  • Localized error messages with a custom locale resolver

Use cases

  • Enforce strong passwords for admin users in a Payload project
  • Apply a consistent password policy across several auth collections
  • Add custom organisation-specific password rules with localized error messages

From the author

Configurable password strength and policy enforcement plugin for Payload CMS

Installation

npm i @payload-kit/password-policy

0

Stars

0

Forks

3

Open Issues

Yesterday

Last Updated

690

Weekly Downloads

v0.1.0-alpha.1

npm Version

49.1 KB

Unpacked Size

0

Dependencies

Repository stars

00 since Nov 22

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 20260
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260

Shared by 5 plugins in gngz/payload-kit.

npm weekly downloads

Trends appear after 7 days of data. Collecting since Dec 2 — 5 daily snapshots so far.

Each point is npm's rolling 7-day download count.

Health Score

69/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1474969753-password-policy.svg)](https://payloaddirectory.dev/plugins/1474969753-password-policy)
HTML
<a href="https://payloaddirectory.dev/plugins/1474969753-password-policy"><img src="https://payloaddirectory.dev/badge/1474969753-password-policy.svg" alt="Payload Directory"></a>
Updated Dec 4, 2026Created Nov 27, 2026Published Nov 29, 2026

README

@payload-kit/password-policy

Password policy plugin for Payload CMS. Enforces composable, localized password rules on auth collections through both a beforeValidate hook and a password field validator (covering create, update, and resetPassword).

Installation

pnpm add @payload-kit/password-policy

Peer dependency: payload (^3.0.0).

Usage

Register passwordPolicyPlugin in payload.config.ts:

import { buildConfig } from "payload";
import { passwordPolicyPlugin } from "@payload-kit/password-policy";

export default buildConfig({
  plugins: [
    passwordPolicyPlugin({
      minLength: 12,
      maxLength: 128,
      defaultLocale: "en",
    }),
  ],
});

Configuration options

OptionTypeDefaultDescription
enabledbooleantrueEnables or disables the plugin. When false, returns the config unchanged.
collectionsstring[]all auth collectionsTarget collection slugs. When omitted, applies to every collection with auth enabled.
minLengthnumber12Minimum password length.
maxLengthnumber128Maximum password length.
requireLowercasebooleantrueRequires at least one lowercase letter.
requireUppercasebooleantrueRequires at least one uppercase letter.
requireNumberbooleantrueRequires at least one digit.
requireSpecialCharbooleantrueRequires at least one non-alphanumeric character.
rejectCommonPasswordsbooleantrueRejects common password fragments, including leetspeak variants (P@ssw0rd).
rejectWeakPatternsbooleantrueRejects repeated runs (aaaa), sequences (1234, wxyz), keyboard runs (qwerty, azerty), and repeated blocks (Ab1!Ab1!Ab1!).
rejectPersonalInfobooleantrueRejects passwords containing the user's name, email local part, or username.
personalInfoFieldsstring[]["email", "name", "username"]Document fields checked by the personal-info rule.
extraRulesreadonly PasswordRule[]undefinedAdditional rules appended after the built-in rules. Each rule receives (password, context) with context.data.
passwordRulesreadonly PasswordRule[]undefinedCustom ruleset that replaces the built-in flags and extraRules.
defaultLocalestring"pt"Fallback locale when a rule has no message for the resolved request locale.
resolveLocale(req: PayloadRequest) => stringundefinedCustom locale resolver for validation error messages.

Behavior and gotchas

  • All checks run offline with no external API calls.
  • Common-password matching normalizes case, accents, and separators.
  • Weak-pattern detection catches 3+ identical consecutive characters, 4+ sequential letters or digits, QWERTY and AZERTY keyboard runs, and blocks repeated 3 or more times.
  • The personal-info check ignores email domains (preventing false positives on shared company domains) and tokens shorter than 4 characters.
  • Validation runs only when a password is created, changed, or reset; existing stored credentials are left untouched.
  • If you place a custom password field inside layout containers (tabs, row, or collapsible), the plugin does not auto-attach its field-level validator to nested fields—use createPasswordField(options, overrides?) so resetPassword and the Admin UI enforce the exact same policy.
  • defaultLocale defaults to "pt". Set defaultLocale: "en" for English-first projects.

Exports

passwordPolicyPlugin, createPasswordField, buildPasswordRules, createPasswordValidator, validatePassword, DEFAULT_PASSWORD_RULES, PASSWORD_MIN_LENGTH, PASSWORD_MAX_LENGTH, and types PasswordLocale, PasswordPolicyOptions, PasswordPolicyPluginOptions, PasswordRule, PasswordRuleContext.

License

MIT

Similar plugins