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

A new IdentityInterface for authentication #2

Open
weierophinney opened this issue Dec 31, 2019 · 4 comments
Open

A new IdentityInterface for authentication #2

weierophinney opened this issue Dec 31, 2019 · 4 comments
Labels

Comments

@weierophinney
Copy link
Contributor

@weierophinney weierophinney commented Dec 31, 2019

This PR is a work in progress to solve the issue about OAuth2 client authentication reported in zendframework/zend-expressive-authentication-oauth2#55. The idea is to use a general IdentityInterface as follows:

namespace Zend\Expressive\Authentication;

interface IdentityInterface
{
    /**
     * Get the unique identity
     */
    public function getIdentity() : string;
}

And a specific UserInterface that extends the IdentityInterface, as follows:

namespace Zend\Expressive\Authentication;

interface UserInterface extends IdentityInterface
{
    /**
     * Get all user roles
     *
     * @return Iterable
     */
    public function getRoles() : iterable;

    /**
     * Get a detail $name if present, $default otherwise
     */
    public function getDetail(string $name, $default = null);

    /**
     * Get all the details, if any
     */
    public function getDetails() : array;
}

Regarding the AuthenticationMiddleware, this PR generates a UserInterface PSR-7 attribute if authenticate($request) returns an instance of UserInterface. Otherwise, it will returns a IdentityInterface attribute.

These changes should prevent BC breaks for existing implementations using zend-expressive-authentication and offers a new solution to zend-expressive-authentication-oauth2 for implementing a ClientInterface (extending IdentityInterface).


Originally posted by @ezimuel at zendframework/zend-expressive-authentication#39

@weierophinney

This comment has been minimized.

Copy link
Contributor Author

@weierophinney weierophinney commented Dec 31, 2019

@ezimuel Is there still work to do on this patch?


Originally posted by @weierophinney at zendframework/zend-expressive-authentication#39 (comment)

@weierophinney

This comment has been minimized.

Copy link
Contributor Author

@weierophinney weierophinney commented Dec 31, 2019

sorry for the super late response - LGTM 👍


Originally posted by @marc-mabe at zendframework/zend-expressive-authentication#39 (comment)

@weierophinney

This comment has been minimized.

Copy link
Contributor Author

@weierophinney weierophinney commented Dec 31, 2019

@ezimuel Is there still work to do on this patch?

@weierophinney this PR is ready, of course we need to implement a new ClientInterface for zend-expressive-authentication-oauth2 to solve zendframework/zend-expressive-authentication-oauth2#55


Originally posted by @ezimuel at zendframework/zend-expressive-authentication#39 (comment)

@weierophinney

This comment has been minimized.

Copy link
Contributor Author

@weierophinney weierophinney commented Dec 31, 2019

I've got this and the related one for oauth2 on my todo list - not sure if I'll have time to evaluate them this week, or if it will be early next. I'll drop a note with what route I go (new minor or new major) when I do.


Originally posted by @weierophinney at zendframework/zend-expressive-authentication#39 (comment)

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.