Skip to content
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 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

Fixes the permission issue with import-all. #379

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

decko
Copy link
Member

@decko decko commented Jun 24, 2024

Closes #373

@decko decko requested review from lubosmj and git-hyagi June 24, 2024 21:04
git-hyagi
git-hyagi previously approved these changes Jun 25, 2024
Copy link
Contributor

@git-hyagi git-hyagi left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 375 to 456
permissions=[
"core.add_compositecontentguard",
"core.add_domain",
"core.add_headercontentguard",
"ostree.add_ostreedistribution",
"ostree.add_ostreeremote",
"ostree.add_ostreerepository",
"ostree.view_ostreerepository",
"ostree.change_ostreerepository",
"ostree.delete_ostreerepository",
"ostree.import_commits_ostreerepository",
"ostree.manage_roles_ostreerepository",
"ostree.modify_ostreerepository",
"ostree.repair_ostreerepository",
"ostree.sync_ostreerepository",
"ostree.view_ostreerepository",
"ostree.add_ostreerepository",
"ostree.view_ostreeremote",
"ostree.change_ostreeremote",
"ostree.delete_ostreeremote",
"ostree.manage_roles_ostreeremote",
"ostree.view_ostreeremote",
"ostree.add_ostreeremote",
"ostree.view_ostreedistribution",
"ostree.change_ostreedistribution",
"ostree.delete_ostreedistribution",
"ostree.manage_roles_ostreedistribution",
"ostree.view_ostreedistribution",
"ostree.add_ostreedistribution",
"core.replicate_upstreampulp",
"core.view_upload",
"core.change_upload",
"core.delete_upload",
"core.manage_roles_upload",
"core.view_upload",
"core.add_upload",
"core.view_task",
"core.change_task",
"core.delete_task",
"core.manage_roles_task",
"core.view_task",
"core.view_taskschedule",
"core.manage_roles_taskschedule",
"core.view_taskschedule",
"core.download_rbaccontentguard",
"core.view_rbaccontentguard",
"core.change_rbaccontentguard",
"core.delete_rbaccontentguard",
"core.manage_roles_rbaccontentguard",
"core.view_rbaccontentguard",
"core.add_rbaccontentguard",
"core.view_headercontentguard",
"core.change_headercontentguard",
"core.delete_headercontentguard",
"core.manage_roles_headercontentguard",
"core.view_headercontentguard",
"core.add_headercontentguard",
"core.view_group",
"core.change_group",
"core.delete_group",
"core.manage_roles_group",
"core.view_group",
"core.add_group",
"core.view_domain",
"core.change_domain",
"core.delete_domain",
"core.manage_roles_domain",
"core.view_domain",
"core.add_domain",
"core.view_contentredirectcontentguard",
"core.change_contentredirectcontentguard",
"core.delete_contentredirectcontentguard",
"core.manage_roles_contentredirectcontentguard",
"core.view_contentredirectcontentguard",
"core.add_contentredirectcontentguard",
"core.view_compositecontentguard",
"core.change_compositecontentguard",
"core.delete_compositecontentguard",
"core.manage_roles_compositecontentguard",
"core.view_compositecontentguard",
"core.add_compositecontentguard",
],
Copy link
Member

@lubosmj lubosmj Jun 25, 2024

Choose a reason for hiding this comment

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

Suggested change
permissions=[
"core.add_compositecontentguard",
"core.add_domain",
"core.add_headercontentguard",
"ostree.add_ostreedistribution",
"ostree.add_ostreeremote",
"ostree.add_ostreerepository",
"ostree.view_ostreerepository",
"ostree.change_ostreerepository",
"ostree.delete_ostreerepository",
"ostree.import_commits_ostreerepository",
"ostree.manage_roles_ostreerepository",
"ostree.modify_ostreerepository",
"ostree.repair_ostreerepository",
"ostree.sync_ostreerepository",
"ostree.view_ostreerepository",
"ostree.add_ostreerepository",
"ostree.view_ostreeremote",
"ostree.change_ostreeremote",
"ostree.delete_ostreeremote",
"ostree.manage_roles_ostreeremote",
"ostree.view_ostreeremote",
"ostree.add_ostreeremote",
"ostree.view_ostreedistribution",
"ostree.change_ostreedistribution",
"ostree.delete_ostreedistribution",
"ostree.manage_roles_ostreedistribution",
"ostree.view_ostreedistribution",
"ostree.add_ostreedistribution",
"core.replicate_upstreampulp",
"core.view_upload",
"core.change_upload",
"core.delete_upload",
"core.manage_roles_upload",
"core.view_upload",
"core.add_upload",
"core.view_task",
"core.change_task",
"core.delete_task",
"core.manage_roles_task",
"core.view_task",
"core.view_taskschedule",
"core.manage_roles_taskschedule",
"core.view_taskschedule",
"core.download_rbaccontentguard",
"core.view_rbaccontentguard",
"core.change_rbaccontentguard",
"core.delete_rbaccontentguard",
"core.manage_roles_rbaccontentguard",
"core.view_rbaccontentguard",
"core.add_rbaccontentguard",
"core.view_headercontentguard",
"core.change_headercontentguard",
"core.delete_headercontentguard",
"core.manage_roles_headercontentguard",
"core.view_headercontentguard",
"core.add_headercontentguard",
"core.view_group",
"core.change_group",
"core.delete_group",
"core.manage_roles_group",
"core.view_group",
"core.add_group",
"core.view_domain",
"core.change_domain",
"core.delete_domain",
"core.manage_roles_domain",
"core.view_domain",
"core.add_domain",
"core.view_contentredirectcontentguard",
"core.change_contentredirectcontentguard",
"core.delete_contentredirectcontentguard",
"core.manage_roles_contentredirectcontentguard",
"core.view_contentredirectcontentguard",
"core.add_contentredirectcontentguard",
"core.view_compositecontentguard",
"core.change_compositecontentguard",
"core.delete_compositecontentguard",
"core.manage_roles_compositecontentguard",
"core.view_compositecontentguard",
"core.add_compositecontentguard",
],
permissions=[
"ostree.add_ostreerepository",
],

We can use just one permission. The other remaining are automatically assigned to a user after the creation.

Copy link
Member

Choose a reason for hiding this comment

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

Or better, we could create a user with the ostree.ostreerepository_creator role.

Copy link
Member

Choose a reason for hiding this comment

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

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've tested with those permissions because we've created an ostree.admin role for services. But for sure we can trim down the permissions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Not really. Because that permission will be automatically assigned to a respective user once she creates a repository, see the creation hooks here:

"creation_hooks": [
{
"function": "add_roles_for_object_creator",
"parameters": {"roles": "ostree.ostreerepository_owner"},
},
],
"queryset_scoping": {"function": "scope_queryset"},
}
LOCKED_ROLES = {
"ostree.ostreerepository_creator": ["ostree.add_ostreerepository"],
"ostree.ostreerepository_owner": [
"ostree.view_ostreerepository",
"ostree.change_ostreerepository",
"ostree.delete_ostreerepository",
"ostree.modify_ostreerepository",
"ostree.sync_ostreerepository",
"ostree.manage_roles_ostreerepository",
"ostree.repair_ostreerepository",
"ostree.import_commits_ostreerepository",
],
.

Copy link
Member

Choose a reason for hiding this comment

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

Please don't use permissions, but roles.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks folks. I've applied all your suggestions.

@lubosmj
Copy link
Member

lubosmj commented Jun 25, 2024

Do we want to backport this to 2.4? 🤔

@lubosmj lubosmj merged commit 94ed3e5 into pulp:main Jun 26, 2024
16 checks passed
Copy link

patchback bot commented Jun 26, 2024

Backport to 2.4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/2.4/94ed3e570a8fdb60ad926f159bea50abe49ad49d/pr-379

Backported as #380

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@decko
Copy link
Member Author

decko commented Jun 26, 2024

Do we want to backport this to 2.4? 🤔

I believe it should be just to 2.3.

Copy link

patchback bot commented Jun 26, 2024

Backport to 2.3: 💚 backport PR created

✅ Backport PR branch: patchback/backports/2.3/94ed3e570a8fdb60ad926f159bea50abe49ad49d/pr-379

Backported as #381

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permission denied when using ostree import-all CLI command.
4 participants