Skip to content

Conversation

tkalir
Copy link
Contributor

@tkalir tkalir commented Aug 12, 2025

Related to #8201

Following the discussion here
This pr introduces permission objects to be used both in the auth flow and later in doc generation flow.
This pr deals with endpoints that use ObjectArn resources (with no AND nodes).

I tested manually committing new objects to branch, which means UploadObject and StageObject work.

@arielshaqed
Assuming this direction seems good, do you have a suggestion how to make this more reviewable \ testable?
I guess I shouldn't create a PR for each resource type, but having everything in one pr seems hard to manage.
I also wonder if there is a way to avoid trying every single endpoint manually.

Copy link
Contributor

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

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

This looks like a great strategy, thanks!

I think many edits of authorize() calls are missing here. This is great if we're doing a trial run for this implementation strategy, but of course blocks actually pulling this PR. So obviously blocking on that - but that does not itself signal any issues!

@@ -111,6 +111,10 @@ type Controller struct {
licenseManager license.Manager
}

type AuthOpts struct {
callback func(w http.ResponseWriter, r *http.Request, code int, v interface{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add at least one, and possibly all, of these:

  • a type for v
  • documentation for the fields code and v
  • documentation of callback: when is it called? what does it do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently all endpoints except 2 call authorize() which calls authorizeCallback() with writeError as callback. There are 2 endpoints which call authorizeCallback directly with a different callback.
So when a function is supplied here it is used as callback instead of writeError.

I used the same signature with the same parameter names as in authorizeCallback, because I think it's clearer if they match. after your comment I changed the variable names in both places to be more informative, tell me what you think.

}) {
if !c.authorizeReq(w, r, "HeadObject", permissions.PermissionParams{Repository: &repository, Path: &params.Path},
&AuthOpts{callback: func(w http.ResponseWriter, r *http.Request, code int, v interface{}) {
writeResponse(w, r, code, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the different callback here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to be clear, I didn't change the callback that is used here. but I believe the reason is that authorize() uses writeError as callback, which adds an error message to the response body when authorizeCallback fails. HeadObject is a Head endpoint, so it shouldn't have a body in the response.
I can add this as a comment.

@tkalir
Copy link
Contributor Author

tkalir commented Aug 13, 2025

@arielshaqed
Thanks

As I mentioned in the description, this PR only handles the endpoints that use a single-node permission with ObjectArn.
My aim was to get early feedback before I write more code, but also to suggest splitting this change to separate PRs. I can make a PR for each resource type or so, to make this more reviewable and easier to test.

Alternatively, I can do each resource type in a different commit, which can also make it easier to review. Let me know what you prefer, or if you have other suggestions.

@tkalir tkalir requested a review from arielshaqed August 13, 2025 16:58
Copy link
Contributor

@arielshaqed arielshaqed 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 the clear explanations!

I agree with everything you wrote. However I also do not want to overload all our developers with having to understand two models of authorization at the same time.

What I would like to do: let's keep this PR open. And do the rest (or the majority) of API calls as additional PRs, into this branch. At the end, I will merge this PR into trunk and we will have a single change. I will commit to adding any auth changes that happened in the meantime.

WDYT?

@tkalir
Copy link
Contributor Author

tkalir commented Aug 16, 2025

That makes sense, seems like a good solution. So I'll make my next PR branch off this branch.

@tkalir
Copy link
Contributor Author

tkalir commented Aug 20, 2025

Hi,
I tried to open a follow-up PR into this branch and realized I can't choose this branch as base since it doesn't exist on this repo. I could create this PR on my fork since this branch exists on my fork, but not here.

Could you create a branch here so I can open PRs against it?
Once it exists, we can change this PR’s base from master to that new branch (or merge this PR into it directly, since it’s approved), and later merge the branch to master when everything is done. I don’t have permissions to create branches in this repo, so I’ll need your help. WDYT?

@tkalir tkalir requested a review from arielshaqed August 20, 2025 07:58
@arielshaqed
Copy link
Contributor

[...]

Could you create a branch here so I can open PRs against it? Once it exists, we can change this PR’s base from master to that new branch (or merge this PR into it directly, since it’s approved), and later merge the branch to master when everything is done. I don’t have permissions to create branches in this repo, so I’ll need your help. WDYT?

Did it! Note that I added a "feature/" prefix to the branch, it is now feature/adding-permission-descriptors-8201 here.

Copy link
Contributor

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

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

I created the branch. I believe I am not blocking in any way, so submitting a comment to make it "not my turn" on reviews

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