We are building a Rest API and are using an authorization module that is heavily inspired by zfc-rbac. One problem we ran into (and among the reasons why we had to make our own module) was that the assertions class (AssertionInterface) takes an AuthorizationService as an argument.
The API is able to push resource representations of newly created resources to clients/users that are online.
Like this we keep the cached model on the client up to date.
These resources we push to the client(s) render with resource privileges/permissions and these can be different for each user. To render these privileges we need to use the assertions without an AuthorizationService (since the authenticated user (the Identity in the RoleService set in the AuthorizationService ) is not who we are rendering for).
Setting a different $identity in the RoleService or setting another RoleService instance in the AuthorizationService during rendering felt very counter intuitive (and even dangerous).
I considered instantiating a new AuthorizationService for the identity/user we are rendering for and use this instance only for rendering, but it felt very uncomfortable to create an AuthorizationService merely for the purpose of rendering my resources with the correct privileges/permissions.
In the end I ended up changing my assertion model and I made an AssertionInterface that takes $identity (IdentityInterface) as a parameter instead of AuthorizationService. This allowed me to use my assertions with other then the currently authenticated Identity.
So what it comes down to is I need to get information on privileges/permissions for a certain identity without having this identity authenticated (so intuitively I would say without an AuthorizationService for this Identity in my application).
Why is the AssertionInterface actually taking an AuthorizationService as an argument instead of an Identity?
Any thoughts on this?
We are building a Rest API and are using an authorization module that is heavily inspired by
zfc-rbac. One problem we ran into (and among the reasons why we had to make our own module) was that the assertions class (AssertionInterface) takes anAuthorizationServiceas an argument.The API is able to push resource representations of newly created resources to clients/users that are online.
Like this we keep the cached model on the client up to date.
These resources we push to the client(s) render with resource privileges/permissions and these can be different for each user. To render these privileges we need to use the assertions without an
AuthorizationService(since the authenticated user (theIdentityin theRoleServiceset in theAuthorizationService) is not who we are rendering for).Setting a different
$identityin theRoleServiceor setting anotherRoleServiceinstance in theAuthorizationServiceduring rendering felt very counter intuitive (and even dangerous).I considered instantiating a new
AuthorizationServicefor the identity/user we are rendering for and use this instance only for rendering, but it felt very uncomfortable to create anAuthorizationServicemerely for the purpose of rendering my resources with the correct privileges/permissions.In the end I ended up changing my assertion model and I made an
AssertionInterfacethat takes$identity(IdentityInterface) as a parameter instead ofAuthorizationService. This allowed me to use my assertions with other then the currently authenticatedIdentity.So what it comes down to is I need to get information on privileges/permissions for a certain identity without having this identity authenticated (so intuitively I would say without an
AuthorizationServicefor this Identity in my application).Why is the
AssertionInterfaceactually taking anAuthorizationServiceas an argument instead of anIdentity?Any thoughts on this?