-
Notifications
You must be signed in to change notification settings - Fork 47
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
Conversation
c1a3da5
to
69dac7d
Compare
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.
minor comments. Looks good otherwise.
relationName, ok := extension.(string) | ||
if !ok { | ||
relationName := relationAsName(relation) | ||
if relationName == "" { |
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.
This seems unrelated. Should it be in a different PR?
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 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.
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.
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) { |
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.
Do we need a feature flag for this?
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 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 == "" { |
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 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) |
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.
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).
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.
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) { |
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 feels like good practice, even if I'm going to turn it on shortly.
e98884b
to
cd9f1ca
Compare
cd9f1ca
to
bc226bf
Compare
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:
Testing
Added a few unit tests, also doing some manual testing.
Review Checklist: