Skip to content
Snippets Groups Projects
Select Git revision
  • 330ae49230c365b1e6a5b148c82dab0c1f4c69dd
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

RouteMap.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    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);
        }
    }