Skip to content
Snippets Groups Projects
Commit 8748dc6d authored by Marko Ivancic's avatar Marko Ivancic
Browse files

WIP

parent 5552a32a
No related branches found
No related tags found
1 merge request!8Fix logut
Pipeline #80995 failed
......@@ -22,7 +22,11 @@ accounting-user-oidc-token-revoke-xhr:
accounting-user-logout:
path: /user/logout
controller: SimpleSAML\Module\accounting\Http\Controllers\User\Profile::logout
controller: SimpleSAML\Module\accounting\Http\Controllers\Logout::logout
methods:
- GET
- POST
accounting-logout:
path: /logged-out
controller: SimpleSAML\Module\accounting\Http\Controllers\Logout::loggedOut
\ No newline at end of file
......@@ -16,6 +16,7 @@ class Routes
public const PATH_USER_PERSONAL_DATA = 'user/personal-data';
public const PATH_USER_OIDC_TOKENS = 'user/oidc-tokens';
public const QUERY_REDIRECT_TO_PATH = 'redirectTo';
public const PATH_LOGGED_OUT = 'logged-out';
protected HTTP $sspHttpUtils;
protected Arr $arr;
......
<?php
declare(strict_types=1);
namespace SimpleSAML\Module\accounting\Http\Controllers;
use Psr\Log\LoggerInterface;
use SimpleSAML\Auth\Simple;
use SimpleSAML\Configuration as SspConfiguration;
use SimpleSAML\Error\ConfigurationError;
use SimpleSAML\Error\CriticalConfigurationError;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Locale\Translate;
use SimpleSAML\Metadata\MetaDataStorageHandler;
use SimpleSAML\Module\accounting\Data\Providers\Builders\DataProviderBuilder;
use SimpleSAML\Module\accounting\Data\Providers\Interfaces\ActivityInterface;
use SimpleSAML\Module\accounting\Data\Providers\Interfaces\DataProviderInterface;
use SimpleSAML\Module\accounting\Entities\Authentication\Protocol\Oidc;
use SimpleSAML\Module\accounting\Entities\ConnectedService;
use SimpleSAML\Module\accounting\Entities\User;
use SimpleSAML\Module\accounting\Exceptions\Exception;
use SimpleSAML\Module\accounting\Exceptions\InvalidConfigurationException;
use SimpleSAML\Module\accounting\Helpers\Attributes;
use SimpleSAML\Module\accounting\Helpers\ProviderResolver;
use SimpleSAML\Module\accounting\Helpers\Routes;
use SimpleSAML\Module\accounting\ModuleConfiguration;
use SimpleSAML\Module\accounting\ModuleConfiguration\ConnectionType;
use SimpleSAML\Module\accounting\Services\AlertsBag;
use SimpleSAML\Module\accounting\Services\CsrfToken;
use SimpleSAML\Module\accounting\Services\HelpersManager;
use SimpleSAML\Module\accounting\Services\MenuManager;
use SimpleSAML\Module\accounting\Services\SspModuleManager;
use SimpleSAML\Module\oidc\Services\OidcOpenIdProviderMetadataService;
use SimpleSAML\Session;
use SimpleSAML\Utils\Config\Metadata;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @psalm-suppress UnusedClass Used as route controller.
*/
class Logout
{
protected ModuleConfiguration $moduleConfiguration;
protected Session $session;
protected LoggerInterface $logger;
protected string $defaultAuthenticationSource;
protected Simple $authSimple;
protected HelpersManager $helpersManager;
protected User $user;
protected SspConfiguration $sspConfiguration;
/**
* @param ModuleConfiguration $moduleConfiguration
* @param SspConfiguration $sspConfiguration
* @param Session $session The current user session.
* @param LoggerInterface $logger
* @param Simple|null $authSimple
* @param HelpersManager|null $helpersManager
*/
public function __construct(
ModuleConfiguration $moduleConfiguration,
SspConfiguration $sspConfiguration,
Session $session,
Simple $authSimple = null,
HelpersManager $helpersManager = null
) {
$this->defaultAuthenticationSource = $moduleConfiguration->getDefaultAuthenticationSource();
$this->sspConfiguration = $sspConfiguration;
$this->authSimple = $authSimple ?? new Simple($this->defaultAuthenticationSource, $sspConfiguration, $session);
$this->helpersManager = $helpersManager ?? new HelpersManager();
}
public function logout(): Response
{
return new RunnableResponse([$this->authSimple, 'logout'], [$this->getLoggedOutUrl()]);
}
public function loggedOut(): Response
{
return new Template($this->sspConfiguration, 'accounting:logged-out.twig');
}
protected function getLoggedOutUrl(): string
{
return $this->helpersManager->getRoutes()->getUrl(Routes::PATH_LOGGED_OUT);
}
}
......@@ -288,21 +288,6 @@ class Profile
return $userIdentifier;
}
public function logout(): Response
{
return new RunnableResponse([$this->authSimple, 'logout'], [$this->getLogoutUrl()]);
}
protected function getLogoutUrl(): string
{
try {
return $this->sspConfiguration->getBasePath() . 'logout.php';
} catch (CriticalConfigurationError $exception) {
$message = \sprintf('Could not resolve SimpleSAMLphp base path. Error was: %s', $exception->getMessage());
throw new InvalidConfigurationException($message, $exception->getCode(), $exception);
}
}
/**
* Load all attribute map files which translate attribute names to user-friendly name format.
*/
......
<!DOCTYPE html>
<html lang="{{ currentLanguage }}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
{# <meta name="viewport" content="initial-scale=1.0">#}
{# <meta http-equiv="X-UA-Compatible" content="IE=Edge">#}
<title>{{ pagetitle }}</title>
<link rel="stylesheet" href="{{ asset('css/src/default.css', 'accounting') }}">
<link rel="icon" href="{{ asset("icons/favicon.ico") }}">
<meta name="robots" content="noindex, nofollow">
</head>
<body id="{{ templateId }}">
{% include '@accounting/includes/_header.twig' %}
<section id="main">
<h1>{{ 'Logout successful'|trans }}</h1>
<p><a href="./user/personal-data">{{ 'Go back to Profile Page'|trans }}</a></p>
</section>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment