Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Add AuthenticationServiceInterface #5901

Conversation

danizord
Copy link
Contributor

@danizord danizord commented Mar 3, 2014

Just to allow dependency inversion.

@@ -9,7 +9,7 @@

namespace Zend\Authentication;

class AuthenticationService
class AuthenticationService implements AuthenticationServiceInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use also {@inheritDoc} in related docblocks here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worst. none of the methods are implemented and the class is not abstract.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface was actually extracted from the implementation, as far as I know

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truth. GH show me an early EOF without many of methods

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius The docblocks are not equal, since the interface don't know about adapters and storages.

@Maks3w
Copy link
Member

Maks3w commented Mar 4, 2014

@danizord Please describe de aim of this PR and complete it if you want the PR to be reviewed


namespace Zend\Authentication;

interface AuthenticationServiceInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a class docblock describing the porpuse of the interface

@danizord
Copy link
Contributor Author

danizord commented Mar 5, 2014

@Maks3w The aim is to be able to typehint AuthenticationServiceInterface instead of AuthenticationService in order to allow other implementations.

@weierophinney weierophinney added this to the 2.3.0 milestone Mar 5, 2014
@fabiocarneiro
Copy link
Contributor

Wow, that's good.

*
* @return void
*/
public function clearIdentity();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking some more about this, I think that we should drop this method from the interface before we're ready to go.

While authenticate, hasIdentity and getIdentity don't imply any mutation of state in the authentication service, clearIdentity obviously does.

This seems like an implementation detail, and most consumers won't need it either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well there is authenticate (login) I see reasonable clearIdentity (logout)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authenticate could well be no-op, while clearIdentity really looks like an expenctancy of state change...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, @Ocramius, as said on IRC, the methods hasIdentity() and getIdentity() means that the service is stateful, so, calling authenticate() will likely change the service state and affect the hasIdentity() and getIdentity() returns.

Anyway, I'm ok to remove clearIdentity() from interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authenticate() writes the discovered identity, if any, to the composed storage object; clearIdentity() removes it. The statefulness is in the underlying storage adapter -- and the AuthenticationService acts as a facade that interacts with the storage adapter, the credential verification adapter, etc.

I'd argue clearIdentity() should remain, @Ocramius -- it's a facade operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about splitting the interface into two?

1 - A interface that only defines authenticate() (implementations can be stateless).
2 - Another interface that extends the first one (or not?) + defines the Identity management API.

Not sure about naming, though.

weierophinney added a commit that referenced this pull request Mar 10, 2014
…-interface

Add AuthenticationServiceInterface
weierophinney added a commit that referenced this pull request Mar 10, 2014
weierophinney added a commit that referenced this pull request Mar 10, 2014
@weierophinney weierophinney merged commit c7fe40e into zendframework:develop Mar 10, 2014
weierophinney added a commit to zendframework/zend-authentication that referenced this pull request May 14, 2015
…ture/authentication-service-interface

Add AuthenticationServiceInterface
weierophinney added a commit to zendframework/zend-authentication that referenced this pull request May 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants