Skip to content

Fix resource when call /projects/<project>#16380

Closed
orblazer wants to merge 1 commit intogoharbor:mainfrom
orblazer:patch-1
Closed

Fix resource when call /projects/<project>#16380
orblazer wants to merge 1 commit intogoharbor:mainfrom
orblazer:patch-1

Conversation

@orblazer
Copy link
Contributor

Hello,
This PR fix resource when we call the root project url like /projects/{project_name_or_id}.
This is an update of #14753 because this issue is still present.

Affected issues : #14512

Affected endpoints :

  • [GET,DELETE,PUT] /projects/{project_name_or_id}
  • [GET] /projects/{project_name_or_id}/_deletable
  • [GET] /projects/{project_name_or_id}/summary

Problem explanation

The bellowing code request resource /project/*

if err := a.RequireProjectAccess(ctx, projectNameOrID, rbac.ActionRead); err != nil {

But this following line generate /project/*/project
Resource: types.Resource(fmt.Sprintf("%s/%s", p.Scope, a.Resource)),

Solution

So that PR fix that by creating custom case when we have request project resource and we have project kind.

Eg of permission enter in this case :

{
  "access": [
    { "action": "read", "resource": "project" }
  ],
  "kind": "project",
  "namespace": "*"
}

Signed-off-by: orblazer <orblazer.minecraft@gmail.com>
@flaviomoringa
Copy link

Hi,

we really need this to create some dashboards on our Backstage app using some information from each project. Any ETA to have this merged and added to a release?

Thanks

@OrlinVasilev OrlinVasilev requested review from a team, Vad1mo and wy65701436 June 2, 2022 15:09
@OrlinVasilev
Copy link
Member

@yanji09 @Vad1mo can you please review!

@Vad1mo
Copy link
Member

Vad1mo commented Jun 2, 2022

@orblazer so far I am fine with this PR. Should we not rather address the root cause mentioned in PR #14753 and the respective fix #15431 that should have fix it?

@MinerYang
Copy link
Contributor

Hi @orblazer ,

We have noticed that this pr is identical with #16381.
We would keep only one and keep tracking on this problem.

Thanks for your contribution!

@MinerYang MinerYang closed this Jul 4, 2022
@orblazer
Copy link
Contributor Author

orblazer commented Jul 5, 2022

Hello @MinerYang,

This PR is similar logic (fix "invalid" permissions on API) but that doesn't affect same urls.

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.

5 participants