Skip to content
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

Allow dot ('.') in relation names #594

Open
matoous opened this issue Jul 28, 2023 · 8 comments
Open

Allow dot ('.') in relation names #594

matoous opened this issue Jul 28, 2023 · 8 comments
Assignees

Comments

@matoous
Copy link
Contributor

matoous commented Jul 28, 2023

Dots (.) are great way to separate and give hierarchical structure to relation (permissions). E.g. repostiories.read or even repositories.contributors.read. As compared to _ (that is supported) they are considered word breaks and imho the semantic would be cleaner than using _ in the same place.

It would be great if Permify supported usage of "." in relation names.

Example based on single role from GCP (see roles and permissions reference):

entity user {}

entity organization {
}

entity project {
    relation parent @organization

    relation owner @user
    relation accessapproval.approver @user

    permission accessapproval.requests.approve = accessapproval.approver or owner
    permission accessapproval.requests.dismiss = accessapproval.approver or owner
    permission accessapproval.requests.get = accessapproval.approver or owner
    permission accessapproval.requests.invalidate = accessapproval.approver or owner
    permission accessapproval.requests.list = accessapproval.approver or owner
    permission accessapproval.serviceAccounts.get = accessapproval.approver or owner

    permission accessapproval.settings.get = accessapproval.approver or owner

    permission resourcemanager.projects.get = accessapproval.approver or owner

    permission resourcemanager.projects.list = accessapproval.approver or owner
}

The GCP is admittedly quite an ower-blownexample but illustrates well how . allow permissions to be structured well into namespace (e.g. resourcemanager) or sub-resources (e.g. resourcemanager.projects). Other separators could be used as well but :and#already have their own syntactical meaning so.` seems like a better choice.

@tolgaOzen
Copy link
Member

Hello @matoous, could you please explain your request in more detail? It would be great if you could do this through an example of a Permify DSL.

@matoous
Copy link
Contributor Author

matoous commented Jul 30, 2023

@tolgaOzen sure! I updated the issue description, would you please take a look if it's more descriptive now?

@tolgaOzen
Copy link
Member

tolgaOzen commented Aug 5, 2023

Hi @matoous, using ‘.’ for hierarchy access can be a bit risky and might cause confusion due to its functionality. To give an example:

entity user {}

entity organization {
    relation admin @user
}

entity project {
    relation parent @organization

    permission accessapproval_requests_approve = parent.admin
}

Here, parent.admin is used to access the admins of the organization. But ‘:’ is not a special symbol in this context. If you'd like, you can open an issue regarding this. We can quickly evaluate it and add it to our roadmap.

@matoous
Copy link
Contributor Author

matoous commented Aug 16, 2023

@tolgaOzen good point, now sure how I missed that. In that case maybe one more thing to consider would be to allow quoting the permissions:

entity user {}

entity organization {
    relation admin @user
}

entity project {
    relation parent @organization
    relation accessapproval.approver @user

    permission accessapproval_requests_approve = parent.admin or "accessapproval.approver"
}

although this is admittedly not very clean.

@ghost
Copy link

ghost commented Oct 12, 2023

I have this same problem... for example a relationship:

If I post to http://localhost:3476/v1/tenants/t1/relationships/write with data

{
    "metadata": {
    },
    "tuples": [
        {
            "entity": {
                "type": "organization",
                "id": "org.2WffVF27PL5VO00JcqYYhiq42m6"
            },
            "relation": "member",
            "subject": {
                "type": "user",
                "id": "acct.2WffVEDWStT0jfiBlcO9vjcwQpd"
            }
        }
    ]
}
Invalid RelationshipWriteRequest.Tuples[0]: embedded message failed validation | caused by: invalid Tuple.Entity: embedded message failed validation | caused by: invalid Entity.Id: value does not match regex pattern \"^(([a-zA-Z0-9_][a-zA-Z0-9_|-]{0,127})|\\\\*)$\"",

We tend to use these style of ids in our app to make it easier to identify some entity ID.

Is there a work around? The only thing I can think of is making a custom client which can encode/decode values... which is not really fun.

@tolgaOzen
Copy link
Member

Hello @slimdevl , yes, we have received feedback regarding this issue. It will be fixed in the next release 🙂

@EgeAytin
Copy link
Member

Hi @slimdevl, we've noticed that your issue is slightly different from the one discussed above, so we've opened a new topic for it. You can track this issue using issue #758

@ghost
Copy link

ghost commented Oct 24, 2023

Thanks Guy! I worked around it using custom json marshallers to modify/unmodify the IDs... Will check it out.

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

No branches or pull requests

3 participants