Skip to content

refactor: standardize permission layers#5094

Open
peterhaochen47 wants to merge 1 commit into
cloudfoundry:mainfrom
peterhaochen47:pr/main/refactor-standardize-perm-layers-may26
Open

refactor: standardize permission layers#5094
peterhaochen47 wants to merge 1 commit into
cloudfoundry:mainfrom
peterhaochen47:pr/main/refactor-standardize-perm-layers-may26

Conversation

@peterhaochen47
Copy link
Copy Markdown
Member

  • such that the codepaths involved become more aligned with the
    following layer design/abstraction:
| Layer | Responsibility |
|-------|---------------|
| **Controller** | Asks `Permissions` (via `permission_queryer`) what the current user can see/do |
| **Permissions** | Translates "can user do X?" into role-set queries via `Membership` |
| **Membership** | Executes role-based database queries (which orgs/spaces does user belong to?) |
| **Models** | Data access, no RBAC logic |
  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@peterhaochen47 peterhaochen47 force-pushed the pr/main/refactor-standardize-perm-layers-may26 branch from 2ecd3ff to 672db0d Compare May 7, 2026 21:29
Comment thread lib/cloud_controller/permissions.rb Outdated

def is_org_manager?
VCAP::CloudController::OrganizationManager.where(user_id: @user.id).any?
membership.authorized_org_guids_subquery(VCAP::CloudController::Membership::ORG_MANAGER).any?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the guid, so authorized_orgs_subquery would be simpler.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed, also made an additional improvement, see message of new commit.

Copy link
Copy Markdown
Member

@philippthun philippthun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the feedback. The second optimization is not needed as we are using the any_not_empty extension:

Sequel::Database.extension(:any_not_empty)

I don't care about using !empty? or any? in this file, but I think the commit message should be adapted as it might be misleading for others.

- such that the codepaths
involved become more aligned with the
following layer design/abstraction:
```
| Layer | Responsibility |
|-------|---------------|
| **Controller** | Asks `Permissions` (via `permission_queryer`) what the current user can see/do |
| **Permissions** | Translates "can user do X?" into role-set queries via `Membership` |
| **Membership** | Executes role-based database queries (which orgs/spaces does user belong to?) |
| **Models** | Data access, no RBAC logic |
```
@peterhaochen47 peterhaochen47 force-pushed the pr/main/refactor-standardize-perm-layers-may26 branch from 6caa741 to a1c6e76 Compare May 12, 2026 18:48
@peterhaochen47
Copy link
Copy Markdown
Member Author

Thanks for addressing the feedback. The second optimization is not needed as we are using the any_not_empty extension:

Sequel::Database.extension(:any_not_empty)

I don't care about using !empty? or any? in this file, but I think the commit message should be adapted as it might be misleading for others.

I see, updated, simply modified the first commit.

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

Successfully merging this pull request may close these issues.

2 participants