src/main/php/auth/ProtectedResource.php
private function isAuthorized(Request $request, Response $response): bool
    {
        $this->authorized = false;
        $user = $this->authenticate($request, $response);
        if (null !== $user && $this->authConstraint->requiresRoles()) {
            $roles = $this->roles($response, $user);
            if (null !== $roles && $this->authConstraint->satisfiedByRoles($roles)) {
                $request->associate(new Identity($user, $roles));
                $this->authorized = true;
            } elseif (null !== $roles) {
                $this->error = $response->forbidden();
            }
        } elseif (null !== $user) {
            $request->associate(new Identity($user, Roles::none()));
            $this->authorized = true;
        }

        return $this->authorized;
    }
private function isAuthorized(Request $request, Response $response): bool
    {
        $this->authorized = false;
        $user = $this->authenticate($request, $response);
        if (null !== $user && $this->authConstraint->requiresRoles()) {
            $roles = $this->roles($response, $user);
            if (null !== $roles && $this->authConstraint->satisfiedByRoles($roles)) {
                $request->associate(new Identity($user, $roles));
                $this->authorized = true;
            } elseif (null !== $roles) {
                $this->error = $response->forbidden();
            }
        } elseif (null !== $user) {
            $request->associate(new Identity($user, Roles::none()));
            $this->authorized = true;
        }

        return $this->authorized;
    }
private function isAuthorized ( Request $ request , Response $ response ) : bool { $ this -> authorized = false ; $ user = $ this -> authenticate ( $ request , $ response ) ; if ( null !== $ user && $ this -> authConstraint -> requiresRoles ( ) ) { $ roles = $ this -> roles ( $ response , $ user ) ; if ( null !== $ roles && $ this -> authConstraint -> satisfiedByRoles ( $ roles ) ) { $ request -> associate ( new Identity ( $ user , $ roles ) ) ; $ this -> authorized = true ; } elseif ( null !== $ roles ) { $ this -> error = $ response -> forbidden ( ) ; } } elseif ( null !== $ user ) { $ request -> associate ( new Identity ( $ user , Roles :: none ( ) ) ) ; $ this -> authorized = true ; } return $ this -> authorized ; }
checks if request is authorized

@param   \stubbles\webapp\Request   $request   current request
@param   \stubbles\webapp\Response  $response  response to send
@return  bool
checks if request is authorized