Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Assertion dependent on Authorization interface #326

@Wilt

Description

@Wilt

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions