Class: GroupDeployKey

Inherits:
Key show all
Defined in:
app/models/group_deploy_key.rb

Constant Summary

Constants included from Expirable

Expirable::DAYS_TO_EXPIRE

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Key

#add_to_authorized_keys, #can_delete?, #ensure_sha256_fingerprint!, #key=, #post_create_hook, #post_destroy_hook, #projects, #public_key, #publishable_key, #refresh_user_cache, regular_keys, #remove_from_authorized_keys, #shell_id, #signing?, #update_last_used_at

Methods included from Expirable

#expired?, #expires?, #expires_soon?

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.defined_enumsObject

Remove usage_type because it defined in Key class but doesn’t have a column in group_deploy_keys table



16
17
18
# File 'app/models/group_deploy_key.rb', line 16

def self.defined_enums
  super.without('usage_type')
end

Instance Method Details

#can_be_edited_for?(user, group) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
# File 'app/models/group_deploy_key.rb', line 28

def can_be_edited_for?(user, group)
  Ability.allowed?(user, :update_group_deploy_key, self) ||
    Ability.allowed?(
      user,
      :update_group_deploy_key_for_group,
      group_deploy_keys_group_for(group)
    )
end

#group_deploy_keys_group_for(group) ⇒ Object



24
25
26
# File 'app/models/group_deploy_key.rb', line 24

def group_deploy_keys_group_for(group)
  group_deploy_keys_groups.find_by(group: group)
end

#group_deploy_keys_groups_for_user(user) ⇒ Object



37
38
39
40
41
# File 'app/models/group_deploy_key.rb', line 37

def group_deploy_keys_groups_for_user(user)
  group_deploy_keys_groups.select do |group_deploy_keys_group|
    Ability.allowed?(user, :read_group, group_deploy_keys_group.group)
  end
end

#typeObject



20
21
22
# File 'app/models/group_deploy_key.rb', line 20

def type
  'DeployKey'
end