Skip to content

Implement modular authentication with improved error handling#2

Open
jane-alesi wants to merge 23 commits into
mainfrom
feature/authentication
Open

Implement modular authentication with improved error handling#2
jane-alesi wants to merge 23 commits into
mainfrom
feature/authentication

Conversation

@jane-alesi

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a modular architecture for the DokuWiki Manager plugin with a focus on authentication and error handling. The changes include:

  • Modular Architecture: Refactored the codebase into separate modules for authentication, API client, and error handling
  • Enhanced Authentication: Added support for both Basic Auth and Bearer Token authentication
  • Improved Error Handling: Implemented comprehensive error handling with user-friendly messages and recovery suggestions
  • Extensive Test Coverage: Added unit tests for all modules with 80%+ coverage
  • Enhanced Documentation: Updated README with detailed architecture documentation and developer guidelines

Implementation Details

Authentication Module (src/auth.js)

  • Supports both Basic Auth and Bearer Token authentication
  • Validates credentials and creates appropriate authentication headers
  • Includes connection testing functionality

API Client Module (src/apiClient.js)

  • Provides a clean interface for JSON-RPC communication
  • Handles API requests with proper error management
  • Adds utility methods for checking page/media existence and wiki info

Error Handler Module (src/errorHandler.js)

  • Maps DokuWiki error codes to user-friendly messages
  • Provides recovery suggestions for common errors
  • Enhances error details for debugging and user assistance

Testing

  • Added comprehensive Jest tests for all modules
  • Configured test coverage thresholds (80%+ for all categories)
  • Used mock implementations for external dependencies

Testing Done

  • Unit tests for all modules
  • Manual integration testing with a DokuWiki instance
  • Verified both authentication methods

Documentation

  • Updated README with detailed architecture information
  • Added developer documentation section
  • Enhanced troubleshooting information

Next Steps

After this PR is merged:

  1. Update the OpenAI function spec in plugin.json to utilize all new features
  2. Add support for additional DokuWiki operations
  3. Implement more comprehensive integration tests

Closes #1 (if there was an issue for this)

jane-alesi and others added 23 commits May 21, 2025 15:15
Introduce a Docker-based development environment for DokuWiki with `docker-compose`, including start/stop scripts. Configure ESLint and Prettier for coding standards, and update scripts in `package.json` for linting and formatting. Adjust `.gitignore` to exclude local dev data while preserving essential files.
    Previously, the entire .idea/ directory was ignored. This change narrows the scope to only ignore workspace.xml, allowing the rest of the .idea/ directory to be included in version control if necessary.
Include shared inspection profiles, run configurations for linting, testing, and script execution, and update `.gitignore` to exclude user-specific files while preserving shared settings. This ensures consistent IDE settings across the team.
Introduce a comprehensive development guide detailing project structure, setup, workflow, and contribution standards. This document aims to streamline onboarding for developers and improve project maintainability.
This commit includes the auto-generated default configuration files (`users.auth.php`, `local.php`, and `acl.auth.php`) for the DokuWiki development setup. It also removes the version declaration from `docker-compose.yml`. These changes are necessary to establish the initial environment for development.
Introduce a new `examples/test-client.js` file to demonstrate usage of the modular API client with a local DokuWiki instance. The script connects to the wiki, retrieves and displays content, lists pages, and creates a new test page. Also, updated the `dev` script in `package.json` to point to the new test client.
The `authMethod` field was added to ensure compatibility with the authentication module. This resolves an issue where the client could not connect due to the missing authentication method configuration.
Relocated configuration files to a new `dokuwiki-config` directory for better organization. Updated local settings to enable remote API access, adjust debugging and security options, and refine ACL rules for development purposes. These changes streamline development workflows and enhance configurability.
Added the savedir path to specify the data storage location. Configured remoteuser to allow any authenticated user, enhancing flexibility for remote access.
Enhanced the `listPages` function to handle various return formats for better robustness and clarity. Added detailed parsing for different page structures and fallback logging for unexpected formats. Removed outdated comments and ensured cleaner output handling.
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.

2 participants