Skip to content

don't override Ability.ability_logic on include #523

Open
@no-reply

Description

@no-reply

Descriptive summary

When Hydra::Ability is included in a class, it overrides all existing ability_logic entries (at https://github.com/samvera/hydra-head/blob/master/hydra-access-controls/lib/hydra/ability.rb#L16). avoid this.

Rationale

Overriding existing ability logic entries silently removes important permissions behavior in the application. This unexpected behavior can occur for reasons as simple as including this module in the "wrong" order.

Expected behavior

class Ability
  self.ability_logic = [:my_custom_ability_hook, :other_ability_hook]
  include Hydra::Ability
end

Ability.ability_logic.include?(:my_custom_ability_hook) # => true

Actual behavior

Ability.ability_logic.include?(:my_custom_ability_hook) # => false

Steps to reproduce the behavior

the easiest way to realistically reproduce is to do something like

class Ability
  include Blacklight::AccessControls::Ability
  self.ability_logic = [:my_custom_ability_hook]
  # more logic here
  # ...
  # and so on
  include Hydra::Ability
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions