Skip to content

Commit

Permalink
Handle exceptions from OIDC based Auth Tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcorbett committed Feb 17, 2023
1 parent c771f70 commit e1c9d77
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions htdocs/web_portal/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
// Require GocContextPath which is used in most of the views scripts
require_once __DIR__.'/GocContextPath.php';

use org\gocdb\security\authentication\BadCredentialsException;

// Set the timezone
date_default_timezone_set("UTC");

Expand Down Expand Up @@ -84,6 +86,18 @@ function rejectIfNotAuthenticated($message = null){
try {
Draw_Page($Page_Type);

} catch (BadCredentialsException $error) {
/**
* `show_view('error.php', ...` is not suitable here.
* - setting raw to FALSE triggers another exception because it tries
* to render a pretty error in a GOCDB window, which fails because the
* user isn't authroised.
* - setting raw to TRUE also isn't ideal as it displays html tags in the
* otherwise nicely formatted output.
* die-ing like this atleast gives the user a somewhart nicely formatted
* error.
*/
die($error->getMessage());
} catch (ErrorException $e) {
/* ErrorExceptions may be thrown by an invalid configuration so it is
not safe to try to give a pretty output. Set 'raw' to true. */
Expand Down

0 comments on commit e1c9d77

Please sign in to comment.