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