Lines
0.00%
0 / 30
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Oidc | 0.00% | 0 / 30 | 0.00% | 0 / 1 | 30 | 0.00% | 0 / 1 | |||
| readResponse | 0.00% | 0 / 30 | 0.00% | 0 / 1 | 30 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package Zmsstatistic | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsstatistic; | |
| 9 | ||
| 10 | use BO\Zmsclient\ModuleAccess; | |
| 11 | use BO\Zmsclient\OidcHandler; | |
| 12 | ||
| 13 | class Oidc extends BaseController | |
| 14 | { | |
| 15 | /** | |
| 16 | * @SuppressWarnings(Param) | |
| 17 | * @return \Psr\Http\Message\ResponseInterface | |
| 18 | */ | |
| 19 | #[\Override] | |
| 20 | public function readResponse( | |
| 21 | \Psr\Http\Message\RequestInterface $request, | |
| 22 | \Psr\Http\Message\ResponseInterface $response, | |
| 23 | array $args | |
| 24 | ): mixed { | |
| 25 | try { | |
| 26 | /** @var \BO\Slim\Request $request */ | |
| 27 | $state = $request->getParam('state'); | |
| 28 | $handler = new OidcHandler(\App::http()); | |
| 29 | $result = $handler->handleCallback($state, 'zmsstatistic'); | |
| 30 | ||
| 31 | if ($wrongModuleResponse = ModuleAccess::rejectWrongModuleAccess(ModuleAccess::MODULE_STATISTIC, $result['workstation'], $response)) { | |
| 32 | return $wrongModuleResponse; | |
| 33 | } | |
| 34 | ||
| 35 | if ($result['redirect_to_index']) { | |
| 36 | return \BO\Slim\Render::redirect( | |
| 37 | 'index', | |
| 38 | [], | |
| 39 | [ | |
| 40 | 'oidclogin' => true | |
| 41 | ] | |
| 42 | ); | |
| 43 | } | |
| 44 | ||
| 45 | return \BO\Slim\Render::redirect( | |
| 46 | 'workstationSelect', | |
| 47 | [], | |
| 48 | [] | |
| 49 | ); | |
| 50 | } catch (\BO\Slim\Exception\OAuthInvalid $e) { | |
| 51 | throw $e; | |
| 52 | } catch (\Exception $e) { | |
| 53 | \App::$log->error('OIDC Login error', [ | |
| 54 | 'event' => 'oauth_login_error', | |
| 55 | 'timestamp' => date('c'), | |
| 56 | 'provider' => \BO\Zmsclient\Auth::getOidcProvider(), | |
| 57 | 'application' => 'zmsstatistic', | |
| 58 | 'error' => $e->getMessage(), | |
| 59 | 'code' => $e->getCode() | |
| 60 | ]); | |
| 61 | throw $e; | |
| 62 | } | |
| 63 | } | |
| 64 | } |