mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00

* WIP ; allow multiple instances of some auth clients (migrate conf) ; add ps-oauth ; remove google+ * WIP ; fix ps-oauth ; fix tests * WIP ; add api-auth to extra_hosts * WIP ; fix yaml syntax error * WIP ; fix yaml syntax error ; better conf sample * WIP ; add "everyone-group" * WIP ; add the provider-id in session * WIP ; add getOptions() to providers (so phr/expose can filter providers) * WIP ; add auto-logout option so logout from phr also logouts from ps-auth * connect to expose using IDP from connected user * WIP ; auto-logout redirects to phr home * unnecessary session var * unused * fix * catch some error * fix navigation in train thumbnail * update file version * pass params in session to have constant redirect_uri ; add debug * invalidate session --> parade test ok * cleanup
282 lines
5.2 KiB
PHP
282 lines
5.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2016 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Authentication\Provider;
|
|
|
|
use Alchemy\Phrasea\Authentication\ACLProvider;
|
|
use Alchemy\Phrasea\Authentication\Provider\Token\Identity;
|
|
use Alchemy\Phrasea\Model\Manipulator\UserManipulator;
|
|
use Alchemy\Phrasea\Model\Repositories\UserRepository;
|
|
use appbox;
|
|
use RandomLib\Generator as RandomGenerator;
|
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|
use Symfony\Component\Routing\Generator\UrlGenerator;
|
|
|
|
abstract class AbstractProvider implements ProviderInterface
|
|
{
|
|
protected $generator;
|
|
protected $session;
|
|
|
|
/**
|
|
* @var bool
|
|
*/
|
|
private $display = true;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $title;
|
|
|
|
/**
|
|
* @var UserManipulator
|
|
*/
|
|
private $userManipulator;
|
|
|
|
/**
|
|
* @var UserRepository
|
|
*/
|
|
private $userRepository;
|
|
|
|
/**
|
|
* @var ACLProvider
|
|
*/
|
|
private $ACLProvider;
|
|
|
|
/**
|
|
* @var appbox
|
|
*/
|
|
private $appbox;
|
|
|
|
/**
|
|
* @var RandomGenerator
|
|
*/
|
|
private $randomGenerator;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private $options = null;
|
|
|
|
private $id;
|
|
|
|
|
|
protected function __construct(UrlGenerator $generator, SessionInterface $session)
|
|
{
|
|
$this->generator = $generator;
|
|
$this->session = $session;
|
|
}
|
|
|
|
public function getId()
|
|
{
|
|
return $this->id ?: $this->getType();
|
|
}
|
|
|
|
public function setId($newId)
|
|
{
|
|
$this->id = $newId;
|
|
return $this;
|
|
}
|
|
|
|
public function getType()
|
|
{
|
|
$u = explode('\\', static::class);
|
|
return array_pop($u);
|
|
}
|
|
|
|
public function getDisplay(): bool
|
|
{
|
|
return $this->display;
|
|
}
|
|
|
|
/**
|
|
* @param bool $display
|
|
*/
|
|
public function setDisplay(bool $display)
|
|
{
|
|
$this->display = $display;
|
|
}
|
|
|
|
/**
|
|
* @deprecated replaced by getTitle()
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->getTitle();
|
|
}
|
|
|
|
/**
|
|
* more clear that getName because the key in conf is "title"
|
|
* @return string
|
|
*/
|
|
public function getTitle()
|
|
{
|
|
return $this->title ?: $this->getId();
|
|
}
|
|
|
|
/**
|
|
* @param string $title
|
|
*/
|
|
public function setTitle(string $title)
|
|
{
|
|
$this->title = $title;
|
|
}
|
|
|
|
/**
|
|
* @param UrlGenerator $generator
|
|
*
|
|
* @return ProviderInterface
|
|
*/
|
|
public function setUrlGenerator(UrlGenerator $generator)
|
|
{
|
|
$this->generator = $generator;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return UrlGenerator
|
|
*/
|
|
public function getUrlGenerator()
|
|
{
|
|
return $this->generator;
|
|
}
|
|
|
|
/**
|
|
* @param SessionInterface $session
|
|
*
|
|
* @return ProviderInterface
|
|
*/
|
|
public function setSession(SessionInterface $session)
|
|
{
|
|
$this->session = $session;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getTemplates(Identity $identity)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* @return SessionInterface
|
|
*/
|
|
public function getSession()
|
|
{
|
|
return $this->session;
|
|
}
|
|
|
|
/**
|
|
* @return UserManipulator
|
|
*/
|
|
public function getUserManipulator(): UserManipulator
|
|
{
|
|
return $this->userManipulator;
|
|
}
|
|
|
|
/**
|
|
* @param UserManipulator $userManipulator
|
|
*/
|
|
public function setUserManipulator(UserManipulator $userManipulator)
|
|
{
|
|
$this->userManipulator = $userManipulator;
|
|
}
|
|
|
|
/**
|
|
* @return UserRepository
|
|
*/
|
|
public function getUserRepository(): UserRepository
|
|
{
|
|
return $this->userRepository;
|
|
}
|
|
|
|
/**
|
|
* @param UserRepository $userRepository
|
|
*/
|
|
public function setUserRepository(UserRepository $userRepository)
|
|
{
|
|
$this->userRepository = $userRepository;
|
|
}
|
|
|
|
/**
|
|
* @return ACLProvider
|
|
*/
|
|
public function getACLProvider(): ACLProvider
|
|
{
|
|
return $this->ACLProvider;
|
|
}
|
|
|
|
/**
|
|
* @param ACLProvider $ACLProvider
|
|
*/
|
|
public function setACLProvider(ACLProvider $ACLProvider)
|
|
{
|
|
$this->ACLProvider = $ACLProvider;
|
|
}
|
|
|
|
/**
|
|
* @return appbox
|
|
*/
|
|
public function getAppbox(): appbox
|
|
{
|
|
return $this->appbox;
|
|
}
|
|
|
|
/**
|
|
* @param appbox $appbox
|
|
*/
|
|
public function setAppbox(appbox $appbox)
|
|
{
|
|
$this->appbox = $appbox;
|
|
}
|
|
|
|
/**
|
|
* @return RandomGenerator
|
|
*/
|
|
public function getRandomGenerator(): RandomGenerator
|
|
{
|
|
return $this->randomGenerator;
|
|
}
|
|
|
|
/**
|
|
* @param RandomGenerator $randomGenerator
|
|
*/
|
|
public function setRandomGenerator(RandomGenerator $randomGenerator)
|
|
{
|
|
$this->randomGenerator = $randomGenerator;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getOptions(): array
|
|
{
|
|
return $this->options;
|
|
}
|
|
|
|
/**
|
|
* @param array $options
|
|
*/
|
|
public function setOptions(array $options)
|
|
{
|
|
$this->options = $options;
|
|
}
|
|
|
|
protected function createState()
|
|
{
|
|
return md5(uniqid(microtime(true), true));
|
|
}
|
|
}
|