blob: 7845d2da9ace9ea07f98e76471fbe5e8de7d32a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php
namespace JsonApi\Routes\SAML;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Routes\Route;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Studip\SAML\SetupInformation;
class ConfigurationUpdate extends Route
{
public function __invoke(Request $request, Response $response, array $args): Response
{
if (!$GLOBALS['perm']->have_perm('root')) {
throw new AuthorizationFailedException();
}
$data = $this->getJsonApiData($request);
$attributes = $data['attributes'] ?? [];
$setupInformation = $this->container->get(SetupInformation::class);
$setupInformation->updateConfiguration($attributes);
$updatedConfig = $setupInformation->getConfiguration();
return $this->jsonResponse($response, [
'data' => [
'type' => 'saml-configuration',
'id' => '1',
'attributes' => $updatedConfig,
],
]);
}
}
|