Skip to content

Commit

Permalink
Add Ownership and Tenancy Mixins to Authentication
Browse files Browse the repository at this point in the history
This adds ownership and tenancy to authentications allowing for key
pairs added by EmsRefresh to be associated with users in manageiq.

https://bugzilla.redhat.com/show_bug.cgi?id=1589766
  • Loading branch information
agrare committed Jul 19, 2018
1 parent ed20ef9 commit 4c6ba95
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def self.new(*args, &block)

serialize :options

include OwnershipMixin
include TenancyMixin

belongs_to :tenant

# TODO: DELETE ME!!!!
ERRORS = {
:incomplete => "Incomplete credentials",
Expand Down
1 change: 1 addition & 0 deletions app/models/miq_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class MiqGroup < ApplicationRecord
has_many :miq_widget_contents, :dependent => :destroy
has_many :miq_widget_sets, :as => :owner, :dependent => :destroy
has_many :miq_product_features, :through => :miq_user_role
has_many :authentications, :dependent => :nullify

virtual_delegate :miq_user_role_name, :to => :entitlement, :allow_nil => true
virtual_column :read_only, :type => :boolean
Expand Down
1 change: 1 addition & 0 deletions app/models/tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Tenant < ApplicationRecord
has_many :miq_request_tasks, :dependent => :destroy
has_many :services, :dependent => :destroy
has_many :shares
has_many :authentications, :dependent => :nullify

belongs_to :default_miq_group, :class_name => "MiqGroup", :dependent => :destroy
belongs_to :source, :polymorphic => true
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class User < ApplicationRecord
has_many :notifications, :through => :notification_recipients
has_many :unseen_notification_recipients, -> { unseen }, :class_name => 'NotificationRecipient'
has_many :unseen_notifications, :through => :unseen_notification_recipients, :source => :notification
has_many :authentications, :foreign_key => :evm_owner_id, :dependent => :nullify, :inverse_of => :evm_owner
belongs_to :current_group, :class_name => "MiqGroup"
has_and_belongs_to_many :miq_groups
scope :superadmins, lambda {
Expand Down

0 comments on commit 4c6ba95

Please sign in to comment.