-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add access control model #26076
Conversation
2055c73
to
af4f3ff
Compare
ee/models/rbac/access_control.py
Outdated
) | ||
|
||
# Optional scope it to a specific role | ||
role: models.ForeignKey = models.ForeignKey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these python code quality checks are weird.... Not sure if something has changed in the way we do foreign key relations? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was from the :models. ForeignKey
types. We don't use those. If we want to then we'd need to do something like
organization_member: Optional[models.ForeignKey["posthog.OrganizationMembership"]] = models.ForeignKey(
"posthog.OrganizationMembership",
on_delete=models.CASCADE,
related_name="access_controls",
related_query_name="access_controls",
null=True,
)
) | ||
|
||
# Configuration of what we are accessing | ||
access_level: models.CharField = models.CharField(max_length=32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we have the available access levels defined somewhere, so could we include choices
in this field to have autovalidation, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to do db level validation to avoid migrations needed so it'll all be in the serializer. Coming soon :)
@@ -5,17 +5,17 @@ | |||
|
|||
|
|||
class Role(UUIDModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes to this file, just clean up.
@@ -138,7 +138,7 @@ def update_billing(self, organization: Organization, data: dict[str, Any]) -> No | |||
|
|||
def update_billing_organization_users(self, organization: Organization) -> None: | |||
try: | |||
distinct_ids = list(organization.members.values_list("distinct_id", flat=True)) | |||
distinct_ids = list(organization.members.values_list("distinct_id", flat=True)) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why these started throwing errors in this PR. I didn't make any changes related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to ignore and update baseline
Changes
Adding the access control model for RBAC. Not changes to functionality and the model is not yet used anywhere
See #24512 for more information.
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
It doesn't have an impact
How did you test this code?
Coming with next PR.