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
integreting with authentication plugin #79
Comments
What is the type of |
This doc on authentication identity shows how you can implement the authentication interface and have your user class used by both plugins. |
I didn't realize that I didn't have to make my own user class? Does the plugin do user class stuff on its own? I'm used to the Auth component, so I just baked a user as usual, and I thought I added everything I needed. It seems the user class is in the 'data' property, but I'm not sure how to access it. $user->data is null?
returns
my user entity is as follows
|
I created an example project with authentication and authorization to better describe the issue. https://github.com/waspinator/cakephp-quickstart/tree/authorization |
You should still make your own user class as it will be easier to add application specific logic. Your user entity also needs to implement the IdentityInterface in the authentication plugin. Then you can follow the directions in the link I gave earlier to have the authentication plugin skip decorating your User object. |
I tried to implement the https://github.com/waspinator/cakephp-quickstart/blob/authorization/app/src/Model/Entity/User.php Authorization can't find the |
Each plugin has its own identity interface. Your class needs to look like: namespace App\Model\Entity;
use Authentication\PasswordHasher\DefaultPasswordHasher;
use Authorization\AuthorizationService;
use Authorization\IdentityInterface as AuthorizationIdentity;
use Authentication\IdentityInterface as AuthenticationIdentity;
use Cake\ORM\Entity;
class User extends Entity implements AuthorizationIdentity, AuthenticationIdentity
{
...
} And you'd also need to replace the |
I'm sorry Mark, can you spell out what I need to change? I updated the Application.php
|
If your user class implements both IdentityInterfaces, you don't need to use an |
okay, I think I got it. I was using the wrong type for the $identity parameter.
|
My cakePHP app works with authorization plugin. On phpunit, if i test login with
My User on test is `
and i retrieve this error: Call to undefined method Authentication\Identity::setAuthorization() Any ideas? |
I think you have partially setup using a custom identity object. Your user class should also implement the Authentication\IdentityInterface as well. |
I didn't setup Custom Identity. |
Please open a new issue if something isn't working. |
I'm trying to add authentication+authorization to an app using this and its related authentication plugin.
I first followed the guide for using the Authentication plugin, and things seemed to be working okay. After adding Authorization, I'm getting an
Call to undefined method Authentication\Identity::setAuthorization()
error after logging in.My User entity implements the identity interface
class User extends Entity implements IdentityInterface
and has asetAuthorization
function, as described in https://book.cakephp.org/authorization/1.1/en/middleware.html#identity-decoratorIn the a Application
middleware()
function I added the two new middlewares.If I try to return the user directly from the
identityDecorator
I get aInvalid identity returned by decorator. 'Authentication\Identity' does not implement 'Authorization\IdentityInterface'.
runtime exception .Which configuration options am I missing to get things to work together correctly?
The text was updated successfully, but these errors were encountered: