-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix export with system auditor user #14626
Conversation
Hey @tanganellilore thanks for the bug issues and the follow up PR, it helps me get up to speed on the issue. I think what you have here is better than before so I'm good with approving and merging it. I'll note that it does not fix the underlying issue, but that issue is harder to fix. |
Digging into this further. This PR avoids the error in question but the fields are not discovered correctly from the description text blob. Below is what an successful export of the schedule roughly looks like with an admin user vs system auditor. Maybe we should NOT merge this PR. I'm thinking maybe we change it to fail but more gracefully. We don't want users thinking their schedules backed up without actually backing them up. Admin user
System Auditor
|
Dug deeper. We need to decide how we want to handle this case. I say fail, but more gracefully.
Nice highligtht. Probably is required some more changes on api level, but better approach. Fields are missing because are not present in the description and system Auditore user is not able to see post method. This happen on all api that require extract io of post method |
I share your goal. I wonder why we require POST data and fields when doing an |
Yes, this nlis not clear to me.... I checked the conde and probably the reason is related to check the permission and/or role and /or reuse some function. Tomorrow if i have time I will check if i can change Thi beaviour |
@chrismeyersfsu @tanganellilore the POST fields were needed because we provide a number of read-only fields, and my goal when writing this functionality was to avoid loading up the output with extraneous data. Maybe it's ok to fall back to just dumping everything (I don't see much reason to hit OPTIONS if POST isn't going to do the job)...? But how then are you going to distinguish the case when the exporting user legit doesn't have access to the resources? |
Rummaging through the code now, I'll document the sharp edges I see here:
|
@jbradberry you are correct, your post remeber me when i digging into the code ans see why it's used post instead get . The question now could be... Why we need to "hide" the post key in options to user that is read only like system auditor? |
It's a good point, I was thinking myself that we're conflating two things: metadata about the fields and permissions for the current user. It'd be nice to decouple them, but I'll point out that any changes we make to the API won't entirely remove the headaches for us since there is an expectation that different versions of the CLI can work with different versions of the API. The same holds (but worse, since devs frequently forget that we need to keep awxkit in sync with changes in the API) if we solve this problem by hard-coding information in awxkit about what fields are important. |
👍 Philosophically I share this view and direction.
Hmm, this changes my mental model. I was considering export in isolation, but it seems that when I think about export I need to think about import at the same time. Am I correct that the two reasons I quoted from you above is why we can't simply fall back to getting the fields from |
@chrismeyersfsu yeah, I think those are the critical reasons. |
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 think this is fine.
6fa4d9e
to
ac4903b
Compare
ac4903b
to
2b14607
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.
@tanganellilore Can you please update awx_collection/test/awx/test_export.py::test_export_system_auditor
? Your changes are making the test fail, since it presumes that exporting as a system auditor will fail. We're also getting a linting failure.
b212376
to
0e9c6d1
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.
I went ahead and pushed some quick fix commits that I think will pass CI. Will merge if so.
SUMMARY
If we use a system auditor user to export elements like schedules or worklows (that have schedule) we receive a general error from awx.awx.module (because is wrapped and is not clear what is behind).
Going down in the error itself I notice that issue was the
Insufficient privileges on %s, inferring POST fields from description.
and in theparse_description
function that is called whtn POST action is not visible to "unpriviledge" user.Inside the
parse_description
i notice that argument passed is referring todesc[desc.index('POST') :]
but if the description of API not have any POST section (like schedule) extraction go in error.I think that we can check if
POST
is present in the description and if not use the description itself to extract required data.Otherwhise is better to return an error to end user (or add the POST descriptio where is missing)
Let me know if i need to modify something
This will fix #14635
ISSUE TYPE
COMPONENT NAME
AWX VERSION
ADDITIONAL INFORMATION