Skip to content

Conversation

@byjg
Copy link
Owner

@byjg byjg commented Nov 6, 2025

This major release introduces significant architectural improvements to the PHP AuthUser library, transitioning from closure-based field mapping to a more robust MapperFunctionInterface system. The release also includes
comprehensive Docusaurus documentation, password validation features, and updated dependencies.

🎯 Major Changes

1. Mapper System Refactoring

  • Migrated from closure-based field mapping to MapperFunctionInterface for better extensibility and type safety
  • Introduced new mapper classes:
    • PasswordSha1Mapper - SHA-1 password hashing (with deprecation notice)
    • UserIdGeneratorMapper - Custom user ID generation
    • ClosureMapper - Backward compatibility wrapper for legacy closures
  • Added entity processors:
    • PassThroughEntityProcessor - No-op processor
    • ClosureEntityProcessor - Closure-based entity processing

2. Password Validation System

  • New PasswordDefinition class with configurable password policies:
    • Minimum character requirements
    • Uppercase/lowercase/symbol/number requirements
    • Whitespace, sequential, and repeated character controls
    • Automatic password generation based on rules

3. Database Layer Improvements

  • UsersDBDataset constructor now accepts DatabaseExecutor or DbDriverInterface
  • Automatic conversion from DbDriverInterface to DatabaseExecutor for backward compatibility
  • Enhanced type safety with strict typing throughout

4. JWT Authentication Prioritization

  • Documentation now recommends JWT tokens over session-based authentication
  • SessionContext marked as deprecated (legacy support maintained)
  • Updated authentication flow examples to favor JWT

5. Comprehensive Documentation

  • Complete Docusaurus documentation site with 11 new documentation files:
    • Getting Started & Installation guides
    • Authentication patterns (JWT & session-based)
    • User Management & Properties
    • Custom Fields & Mappers
    • Password Validation
    • Database Storage
    • Comprehensive examples
  • README refactored to focus on quick start with links to detailed docs

6. Dependency Updates

  • Updated to PHP 8.1-8.4 (previously 8.1-8.3)
  • Updated core dependencies to version 6.0:
    • byjg/micro-orm: ^6.0
    • byjg/cache-engine: ^6.0
    • byjg/jwt-wrapper: ^6.0
  • Updated dev dependencies (PHPUnit ^11, Psalm ^6.13)

⚠️ Breaking Changes

Change Impact Migration Path
UserDefinition::defineClosureForUpdate()defineMapperForUpdate() Method signature changed from Closure to MapperFunctionInterface|string Replace closure with mapper class:
$def->defineMapperForUpdate('field', new ClosureMapper($closure)) or use mapper class names
UserDefinition::defineClosureForSelect()defineMapperForSelect() Method signature changed from Closure to MapperFunctionInterface|string Same as above - use mapper classes instead of closures
UserDefinition::getClosureForUpdate()getMapperForUpdate() Return type changed from Closure to MapperFunctionInterface|string Update code to work with mapper instances instead of closures
UserDefinition::defineGenerateKeyClosure() removed Method throws InvalidArgumentException Use defineGenerateKey(MapperFunctionInterface|string) instead
UserDefinition::existsClosure()existsMapper() Method renamed Update method calls to use new name (old method exists but deprecated)
UserDefinition::beforeInsert / beforeUpdate Changed from Closure to EntityProcessorInterface Wrap closures with new ClosureEntityProcessor($closure)
UsersDBDataset constructor parameter order Constructor type changed: DbDriverInterfaceDatabaseExecutor|DbDriverInterface No immediate breaking change - automatic conversion provided, but update type hints
for future compatibility
Core dependencies updated to ^6.0 byjg/micro-orm, byjg/cache-engine, byjg/jwt-wrapper all require version 6.0 Update all ByJG dependencies to version 6.0
Password hashing default (SHA-1) Still uses SHA-1 by default but with prominent deprecation warnings Implement custom password mapper using bcrypt or Argon2 for new projects

✨ New Features

  • Password generation - Generate secure passwords that comply with validation rules
  • Flexible mapper system - Easy to create custom field mappers for any transformation logic
  • Entity processors - Pre-insert/update hooks with proper interfaces
  • Enhanced type safety - Full PHP 8.1+ type hints throughout the codebase
  • Comprehensive test coverage - New tests for password validation, mappers, and core functionality

📚 Documentation

All documentation is now available in the /docs folder and ready for Docusaurus deployment:

  • Complete API documentation with examples
  • Migration guides for breaking changes
  • Security best practices
  • Real-world usage examples

🔄 Backward Compatibility

Legacy methods are maintained with deprecation notices:

  • defineClosureForUpdate() - wraps closure in ClosureMapper
  • defineClosureForSelect() - wraps closure in ClosureMapper
  • getClosureForUpdate() - returns closure wrapper for mappers
  • existsClosure() - calls existsMapper() internally
  • UsersDBDataset auto-converts DbDriverInterface to DatabaseExecutor

🧪 Testing

  • All existing tests updated and passing
  • New test suites for:
    • PasswordDefinition validation and generation
    • MD5 password mapper
    • Updated dataset tests with new mapper system

📦 Installation

composer require byjg/authuser:^6.0

🔗 Related PRs

This PR consolidates multiple feature branches and improvements into the 6.0 release.

byjg and others added 18 commits November 1, 2025 14:24
…tensible field mapping; add new mappers (`ClosureMapper`, `PasswordSha1Mapper`, `UserIdGeneratorMapper`) and processors (`PassThroughEntityProcessor`, `ClosureEntityProcessor`); update dependencies and increase type safety across the codebase.
…mentations, enhance type hinting, support custom ID generation via `UniqueIdGeneratorInterface`, update test cases, and adjust dependencies for compatibility.
…sswords are hashed or preserved correctly during save and update operations, and validate user login functionality.
…aseExecutor|DbDriverInterface` for improved type clarity.
…` for custom key generation, update related methods and tests, replace deprecated messages, enhance type safety, and align with new mapper conventions.
- Created comprehensive documentation in /docs folder with 12 markdown files
- Added sidebar_position to all docs following the order in README.md
- Fixed inaccurate code examples in README.md to match current implementation
- Updated README with links to all documentation sections
- Fixed example.php to use correct API (UsersAnyDataset constructor, SessionContext)
- Organized docs with proper Docusaurus frontmatter and features
- Added detailed guides for:
  * Getting started and installation
  * User management (CRUD operations)
  * Authentication methods (session and JWT)
  * Session context and storage options
  * User properties (custom key-value data)
  * Database storage and schema customization
  * Password validation and generation
  * JWT token authentication
  * Custom fields and extending UserModel
  * Mappers and entity processors
  * Complete working examples
- Removed duplicate and outdated information from README
- Added feature list and improved organization
- All code examples now reflect actual API usage
Consolidated duplicate content and improved documentation structure:

README.md changes:
- Removed duplicate installation examples
- Simplified Basic Usage to single example
- Removed detailed sections (now in specific docs)
- Replaced with Features section linking to docs
- Simplified Dependencies section

docs/getting-started.md changes:
- Removed duplicate Key Features list
- Simplified Quick Example code

docs/authentication.md changes:
- Added cross-reference to Password Validation

docs/custom-fields.md changes:
- Added clarity on when to use vs Database Storage

Benefits:
- Single source of truth for each concept
- Clear navigation through cross-references
- Better maintainability
- Removed text descriptions from Dependencies section
- Now shows only mermaid flowchart with project dependencies
- Dependencies sourced from composer.json:
  * byjg/authuser --> byjg/micro-orm
  * byjg/authuser --> byjg/cache-engine
  * byjg/authuser --> byjg/jwt-wrapper
- Section remains as last section before footer
Removed dependencies section and related information from installation documentation.
…recate `SessionContext` usage, and clarify differences for security and scalability.
Claude/6.0 011 c us fn wv7 y75 uh4 q9vfc px
…cross codebase, remove redundant interfaces and exceptions, and adjust related tests and documentation.
… `getByUsername`, and `getByLoginField` into a single `get` method, update all references, adjust tests, and update documentation accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants