aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/Lti/Controller/AgsBaseController.php
blob: 37a126ddd9f18f0028a68c6b077ac5df3b141224 (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
<?php
namespace Studip\Lti\Controller;

use AuthenticatedController;
use Studip\OAuth2\NegotiatesWithPsr7;
use OAT\Library\Lti1p3Core\Service\Server\LtiServiceServer;
use OAT\Library\Lti1p3Core\Service\Server\Handler\LtiServiceServerRequestHandlerInterface;
use OAT\Library\Lti1p3Core\Security\OAuth2\Validator\RequestAccessTokenValidatorInterface;

abstract class AgsBaseController extends AuthenticatedController
{
    protected $allow_nobody = true;
    protected $with_session = false;

    use NegotiatesWithPsr7;

    protected function renderAgsResponse(
        LtiServiceServerRequestHandlerInterface $requestHandler
    ): void
    {
        $serviceServer = new LtiServiceServer(
            app()->get(RequestAccessTokenValidatorInterface::class),
            $requestHandler
        );

        $this->renderPsrResponse(
            $serviceServer->handle($this->getPsrRequest())
        );
    }
}