Skip to content

Commit f7c6a0a

Browse files
committed
Handle exceptions from OIDC based Auth Tokens
1 parent 2ca4226 commit f7c6a0a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

htdocs/web_portal/index.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
// Require GocContextPath which is used in most of the views scripts
2727
require_once __DIR__.'/GocContextPath.php';
2828

29+
use org\gocdb\security\authentication\BadCredentialsException;
30+
2931
// Set the timezone
3032
date_default_timezone_set("UTC");
3133

@@ -84,6 +86,18 @@ function rejectIfNotAuthenticated($message = null){
8486
try {
8587
Draw_Page($Page_Type);
8688

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

0 commit comments

Comments
 (0)