Skip to content

before_callback_phase hook not invoked in mocked failure scenario #1043

Closed

Description

@agrobbin

Configuration

  • Provider Gem: omniauth-auth0
  • Ruby Version: 2.7.3
  • Framework: Rails 6.1.3.1
  • Platform: macOS

Expected Behavior

before_callback_phase hook is invoked when mocking out a failed auth.

Actual Behavior

before_callback_phase hook is skipped due to lines 343-345 below:

def mock_callback_call
setup_phase
@env['omniauth.origin'] = session.delete('omniauth.origin')
@env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
@env['omniauth.params'] = session.delete('omniauth.params') || {}
mocked_auth = OmniAuth.mock_auth_for(name.to_s)
if mocked_auth.is_a?(Symbol)
fail!(mocked_auth)
else
@env['omniauth.auth'] = mocked_auth
OmniAuth.config.before_callback_phase.call(@env) if OmniAuth.config.before_callback_phase
call_app!
end
end

Steps to Reproduce

In a non-mocked scenario, before_request_phase is always called, as failure can only happen after the callback_call method calls callback_phase. When testing though, if we mock an auth failure via something like this:

OmniAuth.config.mock_auth[:auth0] = :access_denied

The before_request_phase hook is not called, resulting in a different outcome in tests vs. reality.

The change here seems pretty straightforward, but I wanted to confirm that this was not done on purpose. Is there a specific reason this hook should not be run in the mocked failure case?

Activity

  1. added theissue type on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions