Skip to content

Conversation

@pboling
Copy link
Member

@pboling pboling commented Nov 5, 2025

No description provided.

@pboling pboling self-assigned this Nov 5, 2025
Copilot AI review requested due to automatic review settings November 5, 2025 00:09
@pboling pboling force-pushed the feat/integration-tests branch from 2386179 to 85f2f52 Compare November 5, 2025 00:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds OmniAuth 2.x compatibility, improves test infrastructure, and refactors code for better maintainability. The main focus is ensuring the LDAP strategy works correctly with both OmniAuth 1.x and 2.x versions, particularly around request method handling (GET vs POST).

  • Adds version-aware request method handling for OmniAuth >= 2.0 (POST-only)
  • Introduces new integration tests for Roda framework and middleware behavior
  • Refactors code to use modern Ruby syntax and best practices (e.g., || instead of or, class << self)

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/omniauth/strategies/ldap.rb Core changes: adds OmniAuth 2.x compatibility with version detection, POST-only enforcement, auto-redirect on credential submission, refactors map_user to class method, improves code style
spec/spec_helper.rb Adds CI detection logic to skip coverage checks in dev environments, fixes require logic to handle missing matches
spec/sample/roda_app.rb New sample Roda application for integration testing
spec/omniauth/adaptor_spec.rb New test coverage for LDAP adaptor internal methods
spec/integration/roda_integration_spec.rb New integration tests for Roda framework compatibility
spec/integration/middleware_spec.rb New integration tests for OmniAuth middleware behavior
spec/config/debug.rb Removes debug print statement
omniauth-ldap.gemspec Adds roda development dependency
Gemfile.lock Updates with roda gem

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# If credentials were POSTed directly to /auth/:provider, redirect to the callback path.
# This mirrors the behavior of many OmniAuth providers and allows test helpers (like
# OmniAuth::Test::PhonySession) to populate `env['omniauth.auth']` on the callback request.
if request.post? && (request.params["username"] || request.params["password"])
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The condition request.params['username'] || request.params['password'] will trigger a redirect even when only one credential is present or when either is an empty string. This could bypass the missing_credentials? check in callback_phase. Consider using a more precise condition like checking if both parameters are present (non-nil), or document why partial credentials should trigger a redirect.

Suggested change
if request.post? && (request.params["username"] || request.params["password"])
if request.post? && request.params["username"].to_s != "" && request.params["password"].to_s != ""

Copilot uses AI. Check for mistakes.
@pboling pboling force-pushed the feat/integration-tests branch from 85f2f52 to 027e5d5 Compare November 5, 2025 00:22
@pboling pboling merged commit a27e33b into main Nov 5, 2025
26 of 27 checks passed
@pboling pboling deleted the feat/integration-tests branch November 5, 2025 00:29
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