Skip to content

Plugin/GitHub actions#2

Merged
paulhtrott merged 15 commits intopressable:mainfrom
loukie-pressable:plugin/github-actions
May 2, 2025
Merged

Plugin/GitHub actions#2
paulhtrott merged 15 commits intopressable:mainfrom
loukie-pressable:plugin/github-actions

Conversation

@loukie-pressable
Copy link
Copy Markdown
Contributor

@loukie-pressable loukie-pressable commented Apr 11, 2025

Added GitHub Actions

Summary by CodeRabbit

  • New Features
    • Introduced automated GitHub Actions workflow for packaging and releasing plugin updates.
    • Added Ruby script to streamline release creation and asset uploads.
  • Bug Fixes
    • Improved multisite compatibility and login redirection reliability.
    • Enhanced security for logout functionality with nonce verification and safer credential handling.
    • Added exclusion for specific API and XML-RPC endpoints to bypass Basic Authentication.
  • Documentation
    • Added comprehensive README and plugin readme files detailing features, usage, and FAQs.
  • Chores
    • Added .gitignore and .gitattributes for better repository management and export handling.

Copy link
Copy Markdown
Contributor Author

@loukie-pressable loukie-pressable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 21, 2025

Walkthrough

This update introduces configuration files for Git attributes and ignore rules, along with a new GitHub Actions workflow and a Ruby script to automate release creation and asset uploading. It adds comprehensive documentation files (README.md and readme.txt) for the "Pressable Basic Authentication" WordPress plugin. The main plugin file is updated to version 1.0.1, adding logic to skip Basic Authentication on specific XML-RPC and REST API endpoints, improving request handling. No changes were made to exported or public entities.

Changes

Files / Paths Change Summary
.gitattributes, .gitignore Added .gitattributes to normalize line endings and exclude specified files/directories from export archives. Added .gitignore to exclude vendor, IDE configs, release directories, system files, and archives from version control.
.github/workflows/main.yml, .github/workflows/build.rb Added a GitHub Actions workflow to automate build and release on pushes to main. Introduced a Ruby script that reads version info, creates a GitHub release, and uploads a ZIP asset using Octokit and environment variables.
README.md, readme.txt Added detailed user documentation and WordPress plugin metadata, including features, requirements, FAQs, installation instructions, and changelog placeholders for the "Pressable Basic Authentication" plugin.
pressable-basic-authentication.php Bumped plugin version to 1.0.1. Added a private method to skip Basic Authentication for requests to xmlrpc.php and certain REST API endpoints. Updated init() to bypass authentication for these endpoints. No other control flow or public API changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant WordPress
    participant Plugin (Pressable_Basic_Auth)

    User->>Browser: Access site page
    Browser->>WordPress: HTTP request
    WordPress->>Plugin (Pressable_Basic_Auth): Init hooks
    Plugin (Pressable_Basic_Auth)->>Plugin (Pressable_Basic_Auth): should_skip_auth()?
    alt Skip auth for XML-RPC or REST API
        Plugin (Pressable_Basic_Auth)->>WordPress: Allow access without Basic Auth
    else Require Basic Auth
        Plugin (Pressable_Basic_Auth)->>Browser: Send 401 Basic Auth challenge
        Browser->>User: Prompt for credentials
        User->>Browser: Provide credentials
        Browser->>WordPress: Retry with credentials
        Plugin (Pressable_Basic_Auth)->>WordPress: Validate credentials
        alt Valid
            Plugin (Pressable_Basic_Auth)->>WordPress: Allow access
        else Invalid
            Plugin (Pressable_Basic_Auth)->>WordPress: Log failure (if enabled)
            Plugin (Pressable_Basic_Auth)->>Browser: Send 401 again
        end
    end
Loading

Poem

🐇
A hop, a skip, new skips in sight,
XML-RPC and REST take flight.
Workflows hum, releases gleam,
Docs and ignores join the team.
Auth flows smarter, plugin refined,
Bunny’s joy in every line!
🎉🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9f13d1 and 6c94757.

📒 Files selected for processing (1)
  • README.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🔭 Outside diff range comments (1)
.github/workflows/build.rb (1)

1-41: 🛠️ Refactor suggestion

Verify environment variables before execution

The script assumes several environment variables are present without validating them, which could lead to unexpected errors.

Add this validation at the beginning of the script:

required_vars = [
  'VERSION_FILE_PATH',
  'GITHUB_TOKEN',
  'REPO_NAME',
  'REPO_SHA',
  'ZIP_FILE_NAME',
  'PROJECT_ZIP_NAME'
]

missing_vars = required_vars.select { |var| ENV[var].nil? || ENV[var].empty? }

if missing_vars.any?
  puts "Error: Missing required environment variables: #{missing_vars.join(', ')}"
  exit 1
end
🧰 Tools
🪛 RuboCop (1.73)

[warning] 1-1: Script file build.rb doesn't have execute permission.

(Lint/ScriptPermission)

♻️ Duplicate comments (1)
LICENSE (1)

335-339: Avoid modifying the official GPLv2 text
License files carry legal weight, and even small formatting changes can have unintended consequences. Please revert this change to match the unmodified GNU GPLv2 text as published by the Free Software Foundation.
Paulhtrott: Do not make changes to this license file

🧹 Nitpick comments (3)
.github/workflows/main.yml (2)

3-7: Consider adding pull_request triggers
Running CI only on pushes to main misses validation on branches and PRs. To catch issues earlier, you may want to include:

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

30-32: Pin the Octokit gem version
Installing without a version constraint may lead to unexpected breaking changes. Consider:

-      - name: Install Octokit Gem
-        run: gem install octokit
+      - name: Install Octokit Gem
+        run: gem install octokit -v '~> 4.0'
README.md (1)

49-53: Inconsistent list style

The changelog section uses asterisks for list items, while the rest of the document uses dashes. This inconsistency was flagged by the markdown linter.

-* Initial release with complete Basic Authentication functionality
-* Includes proper logout handling
-* Adds multisite support with Super Admin bypass
-* Implements proper redirects from wp-login.php
+- Initial release with complete Basic Authentication functionality
+- Includes proper logout handling
+- Adds multisite support with Super Admin bypass
+- Implements proper redirects from wp-login.php
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

50-50: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


51-51: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


52-52: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


53-53: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78fac21 and 46ef744.

📒 Files selected for processing (7)
  • .gitattributes (1 hunks)
  • .github/workflows/build.rb (1 hunks)
  • .github/workflows/main.yml (1 hunks)
  • .gitignore (1 hunks)
  • LICENSE (1 hunks)
  • README.md (1 hunks)
  • readme.txt (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/main.yml

19-19: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 RuboCop (1.73)
.github/workflows/build.rb

[warning] 1-1: Script file build.rb doesn't have execute permission.

(Lint/ScriptPermission)

🪛 markdownlint-cli2 (0.17.2)
README.md

50-50: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


51-51: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


52-52: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


53-53: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🔇 Additional comments (4)
.gitattributes (1)

1-17: LF normalization and export-ignore rules look good
This configuration will ensure consistent line endings and exclude the correct files/directories from your release archives.

.gitignore (1)

1-9: Ignore patterns are appropriate
The file correctly excludes build artifacts, IDE settings, and other environment-specific files.

.github/workflows/main.yml (1)

8-11: Verify the VERSION_FILE_PATH
Ensure ./pressable-basic-authentication.php exists at the repo root and contains the correct version constant for tag extraction.

README.md (1)

57-57:

Details

✅ Verification successful

Check that LICENSE file is accessible

The README links to a LICENSE file, but based on a previous review comment "This returns a not found, not worth adding", it might not be accessible. Verify that the LICENSE file exists and is properly accessible.


🏁 Script executed:

#!/bin/bash
# Check if LICENSE file exists
if [ -f "LICENSE" ]; then
  echo "LICENSE file exists"
else
  echo "LICENSE file is missing!"
fi

Length of output: 69


LICENSE file present; no action needed

The LICENSE file exists at the repository root, so the [LICENSE](LICENSE) link in the README will resolve correctly.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/main.yml (1)

18-20: Verified checkout step uses updated action version
You are using actions/checkout@v3, which addresses past concerns and includes important fixes.

🧰 Tools
🪛 actionlint (1.7.4)

19-19: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🧹 Nitpick comments (3)
.github/workflows/main.yml (2)

30-32: Optimize gem installation
Consider adding the --no-document flag to gem install octokit to skip documentation generation and speed up installation:

- run: gem install octokit
+ run: gem install octokit --no-document

33-42: Clean up redundant environment variables
Both ZIP_FILE_NAME and PROJECT_ZIP_NAME are set to the same value. You can remove one to simplify the script, e.g.:

-          PROJECT_ZIP_NAME: ${{ env.PROJECT_NAME }}.zip
README.md (1)

49-54: Align list style in changelog
Use dashes instead of asterisks to maintain consistency with other lists:

- * Initial release with complete Basic Authentication functionality
- * Includes proper logout handling
- * Adds multisite support with Super Admin bypass
- * Implements proper redirects from wp-login.php
+ - Initial release with complete Basic Authentication functionality
+ - Includes proper logout handling
+ - Adds multisite support with Super Admin bypass
+ - Implements proper redirects from wp-login.php
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

50-50: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


51-51: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


52-52: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


53-53: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46ef744 and 4195ac2.

📒 Files selected for processing (3)
  • .github/workflows/main.yml (1 hunks)
  • README.md (1 hunks)
  • readme.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • readme.txt
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/main.yml

19-19: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 markdownlint-cli2 (0.17.2)
README.md

50-50: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


51-51: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


52-52: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


53-53: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🔇 Additional comments (9)
.github/workflows/main.yml (3)

1-7: Approve workflow trigger and naming
The name and on.push.branches fields correctly define the workflow identification and ensure it only runs on pushes to the main branch.


8-11: Approve environment variable setup
Defining PROJECT_NAME and VERSION_FILE_PATH as env variables makes these values reusable across all steps.


21-26: Approve Ruby setup step
Using ruby/setup-ruby@v1 with bundler-cache enabled is a best practice for Ruby projects and speeds up subsequent runs.

README.md (6)

1-3: Approve title and plugin description
The title and introductory blurb clearly explain the plugin’s purpose.


7-11: Approve descriptive use-case list
The list of scenarios where the plugin is useful is concise and well-formatted.


13-20: Approve key features section
The bullet points effectively outline the plugin’s main capabilities.


24-26: Approve requirements section
Minimum version requirements are aligned with readme.txt and clearly stated.


30-36: Approve FAQ section
The FAQ addresses common concerns and provides actionable troubleshooting steps.


43-46: Approve plugin disable instructions
Clear guidance is provided for disabling the plugin if locked out.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/build.rb (1)

1-67: Well-structured script with proper error handling

The script is well-organized with comprehensive error handling for:

  • Version extraction
  • GitHub token validation
  • Release creation
  • Asset upload

This follows best practices for automation scripts.

Note: The script execution permission issue was already addressed in the workflow file by using ruby ./.github/workflows/build.rb as mentioned in a previous review.

🧰 Tools
🪛 RuboCop (1.73)

[warning] 1-1: Script file build.rb doesn't have execute permission.

(Lint/ScriptPermission)

🧹 Nitpick comments (2)
.github/workflows/build.rb (1)

20-20: Fix typo in error message

There's a typo in the error message. It currently says "not set to empty" but should say "not set or empty".

-  puts "Error: GITHUB_TOKEN environment variable not set to empty"
+  puts "Error: GITHUB_TOKEN environment variable not set or empty"
README.md (1)

49-53: Use consistent list style for bullet points

The changelog section uses asterisks (*) for list items while the rest of the document uses dashes (-). For consistency, consider using dashes throughout.

### 1.0.0
-* Initial release with complete Basic Authentication functionality
-* Includes proper logout handling
-* Adds multisite support with Super Admin bypass
-* Implements proper redirects from wp-login.php
+- Initial release with complete Basic Authentication functionality
+- Includes proper logout handling
+- Adds multisite support with Super Admin bypass
+- Implements proper redirects from wp-login.php
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

50-50: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


51-51: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


52-52: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


53-53: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4195ac2 and 2fc28b7.

📒 Files selected for processing (2)
  • .github/workflows/build.rb (1 hunks)
  • README.md (1 hunks)
🧰 Additional context used
🪛 RuboCop (1.73)
.github/workflows/build.rb

[warning] 1-1: Script file build.rb doesn't have execute permission.

(Lint/ScriptPermission)

🪛 markdownlint-cli2 (0.17.2)
README.md

50-50: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


51-51: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


52-52: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


53-53: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🔇 Additional comments (1)
README.md (1)

1-57: Comprehensive documentation for plugin features and usage

The README provides clear documentation covering:

  • Plugin purpose and key features
  • System requirements
  • Troubleshooting information
  • Usage instructions for different scenarios

This will be very helpful for users and administrators.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

50-50: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


51-51: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


52-52: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


53-53: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

README.md Outdated
## Requirements

- WordPress 5.0 or higher
- PHP 7.0 or higher
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set to the WordPress version and PHP versions that it was tested on on the platform.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
pressable-basic-authentication.php (2)

207-233: Refresh header + meta-refresh is fragile; prefer wp_safe_redirect() after 401

Reliance on the non-standard Refresh: header and a meta-refresh tag may fail on some clients (e.g. command-line tools, feed readers) and makes automated testing harder. After prompting with 401, you can immediately wp_safe_redirect() while still preventing caching:

- header( 'Refresh: 1; url=' . home_url() );
+ wp_safe_redirect( home_url() );
+ // Allow the 401 to propagate, but stop further processing.
+ exit;

The browser will reuse the new request without credentials, achieving the same logout effect in a more interoperable way.


163-166: Minor: username from Authorization header should be unslashed before sanitizing

base64_decode() can legitimately return back-slash-escaped sequences on some servers (e.g. IIS). For consistency with the earlier branch (lines 93-95), unslash before sanitize_text_field():

-                list( $user, $pw ) = explode( ':', $auth_decoded, 2 );
-                $_SERVER['PHP_AUTH_USER'] = sanitize_text_field( $user );
+                list( $user, $pw ) = explode( ':', $auth_decoded, 2 );
+                $_SERVER['PHP_AUTH_USER'] = sanitize_text_field( wp_unslash( $user ) );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2fc28b7 and 2586c8a.

📒 Files selected for processing (4)
  • LICENSE (2 hunks)
  • README.md (1 hunks)
  • pressable-basic-authentication.php (10 hunks)
  • readme.txt (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • LICENSE
  • readme.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

@pressable pressable deleted a comment from paulhtrott Apr 29, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
pressable-basic-authentication.php (2)

247-253: Improved logout URL with redirect preservation.

The logout URL now includes:

  1. The basic-auth-logout parameter
  2. A security nonce
  3. Preservation of any redirect URL supplied by WordPress core or plugins

This ensures a more seamless user experience by maintaining the intended post-logout destination.


246-246: ⚠️ Potential issue

Syntax error: Missing semicolon.

There's a missing semicolon at the end of the wp_create_nonce() call, which will cause a PHP syntax error.

-		$nonce = wp_create_nonce( 'basic-auth-logout')
+		$nonce = wp_create_nonce( 'basic-auth-logout' );
🧹 Nitpick comments (1)
pressable-basic-authentication.php (1)

75-75: Trailing whitespace detected.

There's unnecessary whitespace at the end of line 75 after the function declaration.

-	private function force_basic_authentication() {		
+	private function force_basic_authentication() {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2586c8a and 1e489ad.

📒 Files selected for processing (1)
  • pressable-basic-authentication.php (10 hunks)
🔇 Additional comments (13)
pressable-basic-authentication.php (13)

11-11: Version number updated.

The plugin version has been increased from 1.0.0 to 1.0.1, which is appropriate for the bug fixes and improvements in this update.


30-35: Good improvement for multisite compatibility.

Adding different initialization hooks based on whether the site is multisite or not is a good practice. Using ms_loaded for multisite ensures the plugin initializes after the network is fully loaded, while plugins_loaded is appropriate for single sites.


40-41: Method renamed for clarity.

Renaming the method from maybe_redirect_from_login_page to handle_login_redirect improves code readability by making the function name more descriptive and action-oriented.


63-65: Security improvement with nonce verification.

Adding nonce verification for the logout action is a good security practice that prevents CSRF attacks. This ensures that logout requests are intentional and originated from authorized sources.


94-94: Proper handling of password input.

Correctly using wp_unslash() without sanitize_text_field() for the password is appropriate, as sanitization could alter special characters in passwords and affect authentication.


119-127: Improved error logging with filter.

Adding the basic_auth_log_errors filter provides flexibility for controlling error logging based on environment. The default behavior of checking WP_DEBUG_LOG is sensible and follows WordPress best practices.


136-136: Text domain correction.

The text domain has been corrected from 'pressable-basic-auth' to 'hosting-basic-authentication', making it consistent with the plugin name and enabling proper translation.


145-148: Proper credential sanitization.

Sanitizing the username while preserving the password intact is the correct approach. Passwords should not be sanitized as they may contain special characters that would be altered by sanitization functions.


163-165: Consistent credential handling.

The same pattern of sanitizing the username but not the password is correctly applied when extracting credentials from the Authorization header.


207-234: Improved logout experience.

The logout process has been enhanced with:

  1. A Refresh header for more reliable redirection
  2. Proper caching prevention
  3. User-friendly HTML page with helpful messages
  4. Fallback link if automatic redirection fails

This creates a much better user experience than the previous implementation.


259-273: Enhanced login page redirect logic.

The login redirect method now includes:

  1. Better sanitization of credentials
  2. Comprehensive checks to avoid redirecting during specific login-related actions
  3. Verification that the user is already logged in

These improvements ensure the redirect only happens when appropriate.


275-289: Robust multisite redirect URL determination.

The redirect URL determination is now more robust:

  1. Uses get_current_blog_id() for reliability in multisite
  2. Provides a fallback to network home URL if the site-specific URL is unavailable
  3. Uses the standard home URL for single sites

This ensures users are always redirected to the appropriate location.


291-299: Added URL validation before redirect.

Adding a check to ensure the redirect URL is not empty before performing the redirect prevents potential issues where a redirect might fail. The fallback to wp_die() with an error message provides clear feedback if something goes wrong.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
readme.txt (2)

9-11: Remove hidden Unicode characters and trailing whitespace
There are zero-width spaces and trailing whitespace on the License URI line (9) and the == Description == header (11), which may break parsers. Please strip these hidden characters.

- License URI: http://www.gnu.org/licenses/gpl-2.0.html​  
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html

- == Description ==​  
+ == Description ==

40-42: Enhance the Screenshots Section
Currently, this section only contains a placeholder. Consider adding actual screenshot references or example images. For example:

== Screenshots ==
* 1. Initial release – Screenshot of the login prompt: screenshots/1.png
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e489ad and ee1e19b.

📒 Files selected for processing (1)
  • readme.txt (1 hunks)
🔇 Additional comments (2)
readme.txt (2)

22-35: FAQ Section: Good to Go
The Frequently Asked Questions and their answers are clearly structured and use the correct heading syntax. No changes needed here.


36-39: Installation Section: Clear and Concise
The installation instructions are straightforward and properly labeled. This aligns with best practices for WordPress plugin readmes.

@paulhtrott paulhtrott merged commit 9e33e65 into pressable:main May 2, 2025
1 check passed
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