Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ability to disable displaying errors directly into the response. #392

Closed
Magiczne opened this issue Jul 7, 2021 · 2 comments · Fixed by #393
Closed

No ability to disable displaying errors directly into the response. #392

Magiczne opened this issue Jul 7, 2021 · 2 comments · Fixed by #393
Milestone

Comments

@Magiczne
Copy link
Contributor

Magiczne commented Jul 7, 2021

Right now, there are places in the library where error messages are displayed directly into the response, mainly:

  1. AuthenticationException. Lines 74-75:
$client->printHTMLHeader($lang->getAuthenticationFailed());
printf(
    $lang->getYouWereNotAuthenticated(),
    htmlentities($client->getURL()),
    isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN']:''
);
  1. CAS.php. Lines 598-602:
if (self::$_PHPCAS_VERBOSE) {
    echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n";
} else {
    echo "<br />\n<b>Error</b>: <font color=\"FF0000\"><b>". DEFAULT_ERROR ."</b><br />\n";
}

Right now the only way to disable this is to make workarounds using buffering or modifying library using composer-patches.
Users may want to handle errors in their own fashion, and displaying messages directly is not a good way to do it.

As a partial solution for first case it could be do like so:

$messages[] = sprintf(
    $lang->getYouWereNotAuthenticated(),
    htmlentities($client->getURL()),
    isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN']:''
);

but it does not solve $client->printHTMLHeader($lang->getAuthenticationFailed()); line and second case.
In my opinion phpCAS should offer some way (preferably config option) to disable writing error messages directly to the response.

@Magiczne Magiczne changed the title No ability to disable displaying errors to the screen. No ability to disable displaying errors directly into the response. Jul 7, 2021
@jfritschi
Copy link
Contributor

Is pretty much a duplicate of #129 and related to #173 and #57

@Magiczne
Copy link
Contributor Author

Magiczne commented Jul 8, 2021

The issues You have pointed out are 7 and 9 years old respectively.

I could try to make PR with simple configuration variable to turn off the messages i have pointed ouy, but making logging modular is out of my scope right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants