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

Role <> username #49

Open
fabioginzel opened this issue Nov 16, 2014 · 8 comments
Open

Role <> username #49

fabioginzel opened this issue Nov 16, 2014 · 8 comments

Comments

@fabioginzel
Copy link

In ZF\MvcAuth\Identity\AuthenticatedIdentity
getRoleId return name but in my case role of user is different of user name.

What's best approach?

@SvenRtbg
Copy link
Contributor

SvenRtbg commented Dec 8, 2014

I think it boils down to: The identity object provided by authentication should be configurable.

That doesn't address your problem directly, but might lead to a solution.

@nuxwin
Copy link
Contributor

nuxwin commented Dec 23, 2015

@fabioginzel

How do yo authenticate your users exactly (which adapter did you use)? Do you handle many roles? You could use a listener to override default role id. Right now, role id is set by authentication adapter during authentication process.

@fabioginzel
Copy link
Author

I write my adapter

@nuxwin
Copy link
Contributor

nuxwin commented Dec 23, 2015

@fabioginzel

So, for instance, if you're using a doctrine object repository authentication adapter, you can set whatever name you want ($identity->setName('<your_role'>), using identity object that should holds your user role.

@fabioginzel
Copy link
Author

Ok, but I think this should be configurable

@nuxwin
Copy link
Contributor

nuxwin commented Dec 23, 2015

@fabioginzel

Well the role is set by adapter through the setName() method. Default behavior doesn't involve extended ACL permissions system. and anyway, adapter are not aware of full identity object. For instance HTTP adapter only know about an username, a realm and credential.

To resume here, Implementation is up to you. You can always hook in the code and call setName() when needed to override default value set by adapters. Adapter are not aware of full user entity. For instance, http authentication adapter only know about a username, realm and credential. There is not way to get another thing than the username at this stage. For http adapter, another way would be to use your own resolver, which can return whatever you want.

@TomHAnderson
Copy link

https://github.com/API-Skeletons/zf-oauth2-doctrine hooks into your user entity and you can authenticate with User Credentials grant https://bshaffer.github.io/oauth2-server-php-docs/grant-types/user-credentials/

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas-api-tools/api-tools-mvc-auth; a new issue has been opened at laminas-api-tools/api-tools-mvc-auth#20.

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

No branches or pull requests

5 participants