Aura.Auth
Aura.Auth copied to clipboard
Aura.Session compatibility
It would be nice if Aura.Auth was "plug compatible" with Aura.Session, so that the included session management could be easily replaced and enhanced by the more featured Aura.Session.
I think that would mean separate interface packages and therefore 3.x bump.
Yes, if it breaks compatibility, it'd have bump to a new major version. I'm ok with that. ;-)
@cxj looking for this now ?
https://github.com/friendsofaura/FOA.Auth_Session_Bundle ( 3 years old, so not sure if all is working as expected. Have not tested those now )
There is already one ;-) .
I think if Aura.Auth just used a compatible API (PHP interface) to its included Session class, then users of it could optionally and easily plug in Aura.Session to get its greater functionality. That would allow Aura.Auth to remain a standalone and not be dependent on anything.
@cxj I do agree. See discussion on google group regarding the topic : https://groups.google.com/d/msg/auraphp/dVpSOV6RnM4/HWynJROLm-gJ .
It appears that Aura.Session's SegmentInterface and Aura.Auth's SegmentInterface are currently 100% compatible, with Aura.Auth's being a subset of the Aura. Session's.
Aura.Auth:
$ fgrep function SegmentInterface.php
public function get($key, $alt = null);
public function set($key, $val);
Aura.Session:
$ fgrep function SegmentInterface.php
public function get($key, $alt = null);
public function set($key, $val);
public function clear();
public function setFlash($key, $val);
public function getFlash($key, $alt = null);
public function clearFlash();
public function getFlashNext($key, $alt = null);
public function setFlashNow($key, $val);
public function clearFlashNow();
public function keepFlash();
Aura.Session strangely does not have an interface definition for the Session class, while Aura.Auth does. However, the Aura\Session\Sesssion class appears to be compatible with Aura\Auth\Session\SessionInterface.
Aura\Auth:
$ fgrep function SessionInterface.php
public function start();
public function resume();
public function regenerateId();
Aura\Session:
$ fgrep 'public function' Session.php
public function __construct(
public function setDeleteCookie($delete_cookie)
public function getSegment($name)
public function isResumable()
public function isStarted()
public function start() // match
public function resume() // match
public function clear()
public function commit()
public function destroy()
public function getCsrfToken()
public function setCacheExpire($expire)
public function getCacheExpire()
public function setCacheLimiter($limiter)
public function getCacheLimiter()
public function setCookieParams(array $params)
public function getCookieParams()
public function getId()
public function regenerateId() // match
public function setName($name)
public function getName()
public function setSavePath($path)
public function getSavePath()
A problem might be the constructors for the Session class. Perhaps some clever use of a Dependency Injection Container might solve this, however.
Aura.Auth:
public function __construct(array $cookie)
Aura.Session:
public function __construct(
SegmentFactory $segment_factory,
CsrfTokenFactory $csrf_token_factory,
Phpfunc $phpfunc,
array $cookies = array(),
$delete_cookie = null
)
Another problem is that Auth\Auth\AuthFactory takes a Segment in its constructor, while Aura\Session\Session expects to generate its own Segments using a SegmentFactory:
public function __construct(
array $cookie,
SessionInterface $session = null,
SegmentInterface $segment = null
)
Constructor is never a problem if the interfaces satisfies. We can create a separate interface package as https://github.com/auraphp/Aura.Filter_Interface . And this doesn't need all those methods, but very limited / commonly used. Rest of it can be in package level itself.
It does not appear that Aura\Filter makes use of Aura\Filter_Interface. For an interface package to be useful, don't we need to have implementations which actually conform to it by using the PHP implements keyword?
If I understand correctly, to do what you are suggesting, there needs to be a new auraphp package named Aura.Session_Interface, correct? If so, can you create that? I do not have commit access to the auraphp project.
Or perhaps there should be just one auraphp Interfaces repository, where interfaces for all of the subprojects are defined. For example:
auraphp/Interfaces contains:
Aura\Interfaces\Filter_InterfaceAura\Interfaces\FailureCollectionInterfaceAura\Interfaces\Payload_InterfaceAura\Interfaces\Session_InterfaceAura\Interfaces\Segment_Interface
Then Aura\Auth\Session could implement Aura\Interfaces\Session_Interface, etc.
May be we need to ping @pmjones regarding the thoughts expressed here. So he can create the repository. I don't have access for it.