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

Get the current user if user context is set. #86

Merged
merged 1 commit into from Oct 27, 2017

Conversation

lfu
Copy link
Member

@lfu lfu commented Oct 11, 2017

PR ManageIQ/manageiq#16089 allows the user_id/group_id/tenant_id to be recorded in the Queue and sets the user context when dispatching the item from the Queue.

This PR would use the user context if it is available when sending events to automate.

Blocks ManageIQ/manageiq#16179.

https://bugzilla.redhat.com/show_bug.cgi?id=1487749
cc @mkanoor

Copy link
Contributor

@mkanoor mkanoor left a comment

Choose a reason for hiding this comment

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

If you want the Queue worker to run the job in a users context you would have to set the user, group,tenant in the q_options
https://github.com/lfu/manageiq-automation_engine/blob/41f94ee0a43c2a023448a82383e7228714f43c7c/lib/miq_automation_engine/engine/miq_ae_event.rb#L124

@@ -115,13 +115,16 @@ def self.process_result(ae_result, aevent)
end

def self.call_automate(obj, attrs, instance_name, options = {})
user = obj.tenant_identity
user = User.current_user || obj.tenant_identity
Copy link
Contributor

Choose a reason for hiding this comment

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

@lfu @gmcculloug
When these events are raised and if the user is part of multiple groups which group should get used. Do we record the group with the events or vm ownership?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mkanoor The user and the group is recorded in the Queue when the event is raised. Then the user is set to the group in the memory when the item get dequeued and processed.

@@ -124,6 +124,14 @@

MiqAeEvent.raise_evm_event("vm_create", vm, :vm => vm)
end

it "has current user" do
User.current_user = user
Copy link
Contributor

Choose a reason for hiding this comment

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

@lfu use User.with_user similar to https://github.com/ManageIQ/manageiq/blob/b978b61737bf8bffcca23ab3710500b1f677d4fe/spec/lib/rbac/filterer_spec.rb#L242

This we we dont have it set for the whole thread.

When sending events to automate, use the user context if it is available.

https://bugzilla.redhat.com/show_bug.cgi?id=1487749
@miq-bot
Copy link
Member

miq-bot commented Oct 18, 2017

Checked commit lfu@d6d39bb with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@lfu
Copy link
Member Author

lfu commented Oct 24, 2017

@mkanoor Please review.

@mkanoor mkanoor merged commit a1683b5 into ManageIQ:master Oct 27, 2017
@mkanoor mkanoor added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 27, 2017
@lfu lfu deleted the event_current_user branch September 29, 2018 14:32
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.

None yet

4 participants