Skip to content

Permisions claim check field with multiple values? #284

@KK7NZY

Description

@KK7NZY

Hello,

I am currently trying to setup a permissions-profile and was hoping to get some feedback on how to handle permissions for referenced entities and/or suggestions on model design.

For example I have something similar to the following:

type Gallery @rootEntity(permissionProfile: “gallery”) {
	name: String!
	portfolios: [Portfolio!] @relation
	gallery: !ID @accessField
}
type Portfolio @rootEntity {
	name: String!
	images: [Image!] @relation(inverseOf: “portfolio”)
}
type Image @rootEntity {
	name: String!
	url: String!
	portfolio: Portfolio! @relation
}
permissionProfile:
  gallery:
    - access: read
      roles:
        - viewer
      restrictions:
        - field: gallery
          claims: galleries

A user with read permissions would be able to access the name field but would get “Not authorized to read Portfolio objects (in Gallery.portfolios)“ when trying to access porfolios of the gallery . The only way I can think to get around this is to add a Ctx extension to each entity and update the permissions-profile to reference the new context field / or create seperate permission for each entity with the correct feld, claim combination.

type Ctx @entityExtension {
	galleryId: ID @accessField
	portfolioId: ID @accessField
	ownerId: ID @accessField
}
type Gallery @rootEntity(permissionProfile: “gallery”) {
	name: String!
	portfolios: [Portfolio!] @relation
	ctx: @accessField
}
type Portfolio @rootEntity(permissionProfile: “portfolio”) {
	...
	ctx: Ctx @accessField
}
type Image @rootEntity {
	...
	ctx: Ctx @accessField
}
permissionProfile:
  gallery:
    - access: read
      roles:
        - viewer
      restrictions:
        - field: ctx.gallery
          claims: galleries
  portfolio:	 
     - access: read
        roles:
          - viewer
       restrictions:
         - field: ctx.gallery
           claim: galleries
         - field: ctx.portfolio
           claim: portfolios

Adding Ctx entity solved the authentication issue but a Portfolio in the example can be referenced by many Gallery entities. A a user with access to one gallery and not the another would get access denied when trying to access portfolio in current setup unless ctx.gallery was an array.

I know it is not possible to to have an array as a field value. Is there something I can do that would resolve the scenario mentioned above. Something like any([claim in field for claim in claims]) if isinstance(field, list) else field in claims

Do I need Ctx or is there a better way to handle this use case ?

I am still learning my way around so any help would be appreciated.

Regards,
John

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions