Skip to content
Snippets Groups Projects
Commit 6ae2d7f9 authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

Create an AuthenticationFactory that allows us to create SimpleSAML\Auth\Simple objects.

This is needed to allow dependency injection in that class. Since the first parameter of the constructor is the ID of the auth source to use, we don't know the value it must take during compilation of the container. We only know what auth source to use when we are in the controller, becase at that point the URL as been parsed and the auth source ID has been passed to the controller as an argument. Therefore, we need to add this factory class as a service to the container, and once we have the auth source ID, we can call the create() method of the factory to obtain a relevant instance of \SimpleSAML\Auth\Simple.
parent c7919f20
No related branches found
No related tags found
No related merge requests found
<?php
namespace SimpleSAML\Auth;
/**
* Factory class to get instances of \SimpleSAML\Auth\Simple for a given authentication source.
*/
class AuthenticationFactory
{
/** @var \SimpleSAML\Configuration */
protected $config;
/** @var \SimpleSAML\Session */
protected $session;
public function __construct(\SimpleSAML\Configuration $config, \SimpleSAML\Session $session)
{
$this->config = $config;
$this->session = $session;
}
/**
* Create a new instance of \SimpleSAML\Auth\Simple for the given authentication source.
*
* @param string $as The identifier of the authentication source, as indexed in the authsources.php configuration
* file.
*
* @return \SimpleSAML\Auth\Simple
*/
public function create($as)
{
return new Simple($as, $this->config, $this->session);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment