password-based-authentication-pattern
Security pattern for implementing password-based authentication. Use when designing login systems with username/password, implementing password storage, hashing, salting, peppering, password policies, or password reset flows. Specialization of the Authentication pattern.
What this skill does
# Password-Based Authentication Security Pattern A subject proves identity by providing a correct identifier (username/email) and corresponding password. Relies on the assumption that only the actual owner knows the correct password. ## Core Components | Role | Type | Responsibility | |------|------|----------------| | **Subject** | Entity | Provides identifier and password | | **Enforcer** | Enforcement Point | Ensures authentication before action processing | | **Verification Manager** | Entity | Collects inputs for password verification | | **Comparator** | Decision Point | Compares hash values | | **Hasher** | Cryptographic Primitive | Calculates hash values | | **Password Store** | Storage | Keeps hash values for registered identities | | **Registrar** | Entity | Handles subject registration | | **Resetter** | Entity | Handles credential reset | | **Password Policy** | Information Point | Rules passwords must satisfy | | **SRNG** | Cryptographic Primitive | Secure random number generator | ### Data Elements - **id**: Identifier (username, email) - **pwd**: Password provided by Subject - **hash(pwd)**: Hash value of password - **salt**: Random value unique per Subject - **pepper**: System-wide secret for additional protection ## Password Hashing ### Required Approach 1. Use modern password hashing algorithms: **Argon2**, **scrypt**, **bcrypt**, or **PBKDF2** 2. Never use general-purpose hash functions (MD5, SHA-1, SHA-256) alone 3. Always use salting (typically automatic with modern algorithms) ### Salting - Add random string unique per Subject before hashing - Ensures identical passwords produce different hashes - Salt stored in plaintext alongside hash - Modern algorithms handle salt automatically ### Peppering (Optional) - System-wide secret added before hashing - Stored separately from password store - Provides additional protection if password store is compromised ## Registration Flow Three approaches for credential determination: 1. Subject provides identifier and password 2. Subject provides identifier; Registrar selects password 3. Registrar selects both identifier and password Upon completion: - Password Store contains: identifier, hash(salted password), salt - Subject possesses: identifier and password ## Password Policy Enforce policies including: - Minimum/maximum length - Character requirements - Common password blacklist - Breach database checking ## Password Reset 1. Verify Subject identity through out-of-band channel 2. Generate time-limited reset token 3. Never reveal whether account exists 4. Invalidate existing sessions after reset 5. Force re-authentication ## Security Considerations ### Password Store Protection - Encrypt at rest - Restrict access - Monitor for breaches - Detect tampering ### Identifier Security - Don't rely on identifier secrecy - Prevent enumeration attacks - Use consistent timing for valid/invalid identifiers ### Verification Timing - Use constant-time comparison - Prevent timing attacks ## Implementation Checklist - [ ] Using Argon2/scrypt/bcrypt/PBKDF2 - [ ] Automatic salting enabled - [ ] Password policy enforced - [ ] Secure reset flow implemented - [ ] Rate limiting on login attempts - [ ] Constant-time hash comparison - [ ] No credential logging ## References - Source: https://securitypatterns.distrinet-research.be/patterns/01_01_002__authentication_pwd/ - OWASP Password Storage Cheat Sheet
Related in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.