Skip to content

michtio/craftcms-claude-skills / skills/craft-plugins

craft-plugins

Verified

Index and router for plugin-specific Craft CMS 5 guidance — configuration, Twig API, PHP API, migrations, deployment, and pitfalls for the plugins this pack documents. Load whenever a task names a plugin this pack documents, and for passwordless or magic-link auth with no plugin named; read references/<plugin>.md first.

references/password-policy.md

View on GitHub
# Password Policy

Password enforcement plugin by CraftPulse. Enforces minimum/maximum length, character requirements (uppercase, lowercase, numbers, symbols), "Have I Been Pwned" database checking, password strength indicator, and password retention/expiry with forced resets. CraftPulse's own plugin.

`craftpulse/craft-password-policy` — Free

## Documentation

- GitHub: https://github.com/craftpulse/craft-password-policy
- Plugin Store: https://plugins.craftcms.com/password-policy

## Common Pitfalls

- Setting `minLength` below 6 — Craft's own minimum is 6 characters. The plugin enforces this as a floor and validation will reject lower values.
- Enabling `pwned` check without considering network latency — the Have I Been Pwned API is called on every password save. For high-traffic registration forms, this adds a network round-trip. It's a security trade-off worth making, but be aware of the performance impact.
- Enabling `retentionUtilities` without configuring `expiryAmount` and `expiryPeriod` — retention features need both values set to work correctly.
- Forgetting that admin (user ID 1) is excluded from forced resets — the retention service intentionally skips the primary admin account to prevent lockout.
- Not running retention checks on a schedule — password expiry only triggers when the retention console command or queue job runs. Set up a cron job.

## Settings

All settings are configured in the CP under Settings → Password Policy, or via config file:

```php
// config/password-policy.php
return [
    '*' => [
        // Minimum password length (floor: 6, Craft's minimum)
        'minLength' => 12,

        // Maximum password length (0 = no maximum)
        'maxLength' => 0,

        // Require mixed case (uppercase + lowercase)
        'cases' => true,

        // Require at least one number
        'numbers' => true,

        // Require at least one special character (!@#$%^&*)
        'symbols' => true,

        // Show password strength indicator in CP
        'showStrengthIndicator' => true,

        // Check password against Have I Been Pwned database
        'pwned' => true,

        // Enable password retention/expiry features
        'retentionUtilities' => false,

        // Password expiry period (amount + period)
        'expiryAmount' => 90,
        'expiryPeriod' => 'day',    // day, week, month, year

        // Generate CSP nonces for inline scripts
        'cspNonce' => false,
    ],
];
```

## How It Works

### Password Validation

The plugin registers custom validation rules on the `User` element via `DefineRulesEvent`. When a user sets or changes their password, the rules enforce:

1. **Length** — minimum (and optional maximum) character count
2. **Character requirements** — mixed case, numbers, symbols (based on settings)
3. **Pwned check** — queries the Have I Been Pwned API using k-anonymity (only the first 5 chars of the SHA-1 hash are sent, never the full password)

The validation pattern is generated dynamically from the enabled settings — only active rules are included in the regex.

### Password Strength Indicator

When `showStrengthIndicator` is enabled, the CP shows a visual strength meter on password fields. This gives editors real-time feedback while typing.

### Password Retention

When `retentionUtilities` is enabled:

- A CP utility page shows retention status and allows manual forced resets
- Expired passwords trigger `passwordResetRequired = true` on the user
- Users must change their password on next login
- The primary admin (user ID 1) is always excluded from forced resets

## Console Commands

```bash
# Force reset all expired passwords (queue job)
ddev craft password-policy/retention/force-reset-passwords

# Force reset with --queue flag (queue only, don't run immediately)
ddev craft password-policy/retention/force-reset-passwords --queue
```

Set up a cron job for automatic retention checking:

```bash
# Check daily at 2am
0 2 * * * cd /var/www/html && php craft password-policy/retention/force-reset-passwords --queue
```

## Architecture

| Service | Responsibility |
|---------|---------------|
| `PasswordService` | Generates validation regex pattern and error messages from settings |
| `RetentionService` | Handles password expiry checks, forced resets via queue jobs |
| `SecurityService` | Security-related utilities |
| `PwnedValidator` | Queries Have I Been Pwned API with k-anonymity |

### Events

The plugin hooks into Craft's user lifecycle via:

- `User::EVENT_DEFINE_RULES` — adds password validation rules
- `View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE` — injects strength indicator JS
- `Plugins::EVENT_AFTER_INSTALL_PLUGIN` — initial setup

## Recommended Settings

For most projects:

```php
'minLength' => 12,
'maxLength' => 0,          // No max — let password managers generate long passwords
'cases' => true,
'numbers' => true,
'symbols' => false,        // Controversial — NIST guidelines no longer recommend
'showStrengthIndicator' => true,
'pwned' => true,           // Always enable — negligible performance cost
'retentionUtilities' => false, // Enable only if compliance requires it
```

## Pair With

- **Sherlock** — security scanning and monitoring alongside password enforcement
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall