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 #36785 - Show permission error page for job wizard #842

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

kmalyjur
Copy link
Contributor

@kmalyjur kmalyjur commented Oct 25, 2023

Depends on theforeman/foreman#9902

It is showing missing permissions needed on the /job_invocations/new page. The "Proceed Anyway" button lets you look at the wizard even though it won't be working properly.
image

On the "Category and template" step it shows a warning alert if view_job_templates permission is missing:
image

On the "Target hosts and inputs" step it shows a warning alert if view_hosts permission is missing:
image

@ofedoren
Copy link
Member

Well, quickly looking at the way we have implemented access control, it seems we only check for one permission per one action. I guess that's why you don't have missing permissions if at least one of them are present. Currently it seems if we add the action into multiple permission blocks, it would treat it as "at least one of those permissions allow this action", which is quite opposite you want to achieve.

As a solution I'd suggest:

  • Either show errors on each requested action (such as loading the page, checking for categories, etc). For loading the page, create_job_invocations permission should be enough.
  • Or adjust the whole system to be able to check for multiple permissions for one action.

But that's just my observations, @adamruzicka, did I miss anything?

@adamruzicka
Copy link
Contributor

Yeah, that's in line with what I've seen. Out of the two options you suggested I'd vote for the second. There are ~five permissions you really need to be able to trigger a job and I'd prefer not getting to the form at all if I'm missing any rather than seeing the form which bunch of unauthorized errors all over the place. Otoh, and maybe that's just me being pessimistic, I'm pretty sure that there's a part of the wider foreman ecosystem which relies on the current behavior when any permission suffices

@kmalyjur
Copy link
Contributor Author

kmalyjur commented Nov 1, 2023

Thank you for your input. I see it the same way. I can somehow work around it and make it function as needed just for this case, but I was unfortunately hoping that there is already a proper way to approach this permission issue.

@ares
Copy link
Member

ares commented Nov 1, 2023

The question is, should we even allow user to get "create_job_invocations" permission without all other 4 required ones? Should it implicitly add these? Should we have any validations? I know this would open a can of worms by introducing dependency between permissions, but from user perspective, I don't want to be able to define meaningless combinations of permissions. With more complex wizards, we'll get to similar situations more often.

EDIT: to be clear, the proper solution IMHO should not block this PR and work around solution is fine by me here

@ofedoren
Copy link
Member

ofedoren commented Nov 1, 2023

Should we then actually kinda enforce using predefined roles? Which can contain all the needed perms?

@kmalyjur
Copy link
Contributor Author

kmalyjur commented Nov 2, 2023

I'm going to write a post on the Discourse about this overall permission issue, so maybe we'll get more opinions/proposals

@kmalyjur kmalyjur force-pushed the show-error-job-permission branch from 1e8ebef to b09c2f4 Compare November 14, 2023 14:31
@kmalyjur kmalyjur marked this pull request as ready for review November 20, 2023 10:12
@kmalyjur
Copy link
Contributor Author

I've updated the PR to be ready for review. The permissions are taken from a new API (theforeman/foreman#9902). Could anyone please take a look at it?

@kmalyjur kmalyjur force-pushed the show-error-job-permission branch from b09c2f4 to 9e37605 Compare November 22, 2023 12:27
Copy link
Contributor

@pondrejk pondrejk left a comment

Choose a reason for hiding this comment

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

ack, checked on stream snap 38 + packit for this and the dependency PR

@pondrejk
Copy link
Contributor

I noticed that it takes a bit of time to display the permission denied panel, first the wizard is displayed, then the panel hops in. But that is just a minor annoyance, otherwise works as described

@kmalyjur
Copy link
Contributor Author

I noticed that it takes a bit of time to display the permission denied panel, first the wizard is displayed, then the panel hops in. But that is just a minor annoyance, otherwise works as described

Thanks for the review. You're right about this - I kinda ignored it, but if it's too annoying, I can for sure add a "loading" page instead of it in the future.

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

Could you please bump the required foreman version in engine.rb to 3.10? Otherwise LGTM

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

Works like a charm

@adamruzicka adamruzicka merged commit f9f7398 into theforeman:master Jan 8, 2024
4 of 5 checks passed
@adamruzicka
Copy link
Contributor

Thank you @kmalyjur , @ofedoren, @ares & @pondrejk !

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