8000 Enable CreateProject and DeleteProject on top-level projects by evankanderson · Pull Request #5586 · mindersec/minder · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enable CreateProject and DeleteProject on top-level projects #5586

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 10000 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

Merged
merged 4 commits into from
Apr 15, 2025

Conversation

evankanderson
Copy link
Member

Summary

Allow CreateProject (with auth but no permission check) on top-level projects.

Allow DeleteProject (with required project permissions) on top-level projects.

Both changes are behind a new feature flag.

Fixes #3173
Fixes #3174

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Added a few unit tests, also doing some manual testing.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@evankanderson evankanderson requested a review from a team as a code owner April 15, 2025 04:32
JAORMX
JAORMX previously approved these changes Apr 15, 2025
Copy link
Contributor
@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

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

minor comments. Looks good otherwise.

relationName, ok := extension.(string)
if !ok {
relationName := relationAsName(relation)
if relationName == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems unrelated. Should it be in a different PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to re-use this logic in handlers_projects.go to get the OpenFGA relation for a specific relation (create), so I extracted this bit of code.

Copy link
Contributor

Choose a reason for hiding this comment

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

gotcha

} else {
// This is a top-level project creation request.
// We need to check if the user has the right to create projects in the system.
if !flags.Bool(ctx, s.featureFlags, flags.ProjectCreateDelete) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a feature flag for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

It feels like good practice, even if I'm going to turn it on shortly.

relationName, ok := extension.(string)
if !ok {
relationName := relationAsName(relation)
if relationName == "" {
Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to re-use this logic in handlers_projects.go to get the OpenFGA relation for a specific relation (create), so I extracted this bit of code.

@@ -111,7 +121,7 @@ func populateEntityContext(
authzClient authz.Client,
req any,
) (context.Context, error) {
projectID, err := getProjectIDFromContext(req)
projectID, err := getProjectIDFromRequest(req)
Copy link
Member Author

Choose a reason for hiding this comment

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

This rename was probably too much -- I can roll it back if you want (Context being an overloaded name between the request field and the Golang concept).

Copy link
Contributor

Choose a reason for hiding this comment

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

nah, it's fine

} else {
// This is a top-level project creation request.
// We need to check if the user has the right to create projects in the system.
if !flags.Bool(ctx, s.featureFlags, flags.ProjectCreateDelete) {
Copy link
Member Author

Choose a reason for hiding this comment

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

It feels like good practice, even if I'm going to turn it on shortly.

@coveralls
Copy link
coveralls commented Apr 15, 2025

Coverage Status

coverage: 56.859% (+0.02%) from 56.838%
when pulling ccea2b3 on evankanderson:free-range-cd
into 6da21b1 on mindersec:main.

@evankanderson evankanderson merged commit 98d69d0 into mindersec:main Apr 15, 2025
25 checks passed
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.

Allow deletion of top-level projects Allow creation of top-level projects
3 participants
0