Skip to content

AuthenticationService::getUnauthenticatedRedirectUrl( Returns Relative URLs Without Ffull Base #684

@ravage84

Description

@ravage84

Description

Why does Authentication\AuthenticationService::getUnauthenticatedRedirectUrl() returns URLs without full base?

return $url['path'] . '?' . $url['query'] . $fragment;

Image

This makes asserting redirects because of unauthenticated access a PITA.

$this->assertRedirect('/login?redirect=' . urlencode($redirect));

Leads to the following test error because of this:

Failed asserting that 'http://localhost/coupon-portal/login?redirect=%2Fcampaigns%2Fposition' equals content in header 'Location' (/coupon-portal/login?redirect=%2Fcampaigns%2Fposition).

Because Cake\TestSuite\IntegrationTestTrait::assertRedirect() always tests against full based URLs:

https://github.com/cakephp/cakephp/blame/33626a03197758f30a8ce8c2e0a75ed8ddbce40a/src/TestSuite/IntegrationTestTrait.php#L929

Wouldn't full based URL redirects be more sensible (& secure) to begin with?

CakePHP Version

4.x & (probably) 5.x

PHP Version

irrelevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions