Select Git revision
ModulInst.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Jan-Hendrik Willms authored
Closes #979 Merge request !564
Jan-Hendrik Willms authoredCloses #979 Merge request !564
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
oauth2_controller.php 1.36 KiB
<?php
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Exception\OAuthServerException;
use Studip\OAuth2\NegotiatesWithPsr7;
abstract class OAuth2Controller extends StudipController
{
use NegotiatesWithPsr7;
/**
* @return void
*/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
page_open([
'sess' => 'Seminar_Session',
'auth' => 'Seminar_Default_Auth',
'perm' => 'Seminar_Perm',
'user' => 'Seminar_User',
]);
$this->set_layout(null);
$this->container = new Studip\OAuth2\Container();
$this->server = $this->getAuthorizationServer();
}
/**
* Exception handler called when the performance of an action raises an
* exception.
*
* @param Exception $exception the thrown exception
*/
public function rescue($exception)
{
if ($exception instanceof OAuthServerException) {
$psrResponse = $exception->generateHttpResponse($this->getPsrResponse());
return $this->convertPsrResponse($psrResponse);
}
return new Trails\Response($exception->getMessage(), [], 500);
}
protected function getAuthorizationServer(): AuthorizationServer
{
return $this->container->get(AuthorizationServer::class);
}
}