Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aura.Session compatibility #86

Open
cxj opened this issue Jun 29, 2017 · 12 comments
Open

Aura.Session compatibility #86

cxj opened this issue Jun 29, 2017 · 12 comments
Assignees

Comments

@cxj
Copy link
Collaborator

cxj commented Jun 29, 2017

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.

@jakejohns
Copy link
Member

I think that would mean separate interface packages and therefore 3.x bump.

@cxj
Copy link
Collaborator Author

cxj commented Jun 30, 2017

Yes, if it breaks compatibility, it'd have bump to a new major version. I'm ok with that. ;-)

@harikt
Copy link
Member

harikt commented Jun 30, 2017

@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 ;-) .

@cxj
Copy link
Collaborator Author

cxj commented Jun 30, 2017

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.

@harikt
Copy link
Member

harikt commented Jun 30, 2017

@cxj I do agree. See discussion on google group regarding the topic : https://groups.google.com/d/msg/auraphp/dVpSOV6RnM4/HWynJROLm-gJ .

@cxj cxj self-assigned this Jul 31, 2019
@cxj
Copy link
Collaborator Author

cxj commented Aug 17, 2019

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();

@cxj
Copy link
Collaborator Author

cxj commented Aug 17, 2019

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()

@cxj
Copy link
Collaborator Author

cxj commented Aug 17, 2019

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
    )

@cxj
Copy link
Collaborator Author

cxj commented Aug 17, 2019

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
    )

@harikt
Copy link
Member

harikt commented Aug 18, 2019

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.

@cxj
Copy link
Collaborator Author

cxj commented Aug 18, 2019

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_Interface
  • Aura\Interfaces\FailureCollectionInterface
  • Aura\Interfaces\Payload_Interface
  • Aura\Interfaces\Session_Interface
  • Aura\Interfaces\Segment_Interface

Then Aura\Auth\Session could implement Aura\Interfaces\Session_Interface, etc.

@harikt
Copy link
Member

harikt commented Aug 19, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants