apsislabs / apsislabs/phi_attrs

Extend PHI Access on `allow_phi` call instead of on extension method call

Open
#60 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
31
Forks
3
PR merge metrics
No merged PRs in 30d

Description

```ruby
# model with associations
class Foo < ActiveRecord::Base
phi_model
belongs_to :bar
has_many :baz

extend_phi_access :bar, :baz
end

# setup associations
foo = Foo.new
bar = Bar.new
baz = Baz.new
foo.bar = bar
foo.baz << baz

# PHI access is not extended until we call the wrapped method
foo.allow_phi!('me', 'reason')
foo.association(:bar).reader.phi_allowed? # => false
foo.bar.phi_allowed? # => true
foo.association(:bar).reader.phi_allowed? # => true

# desired outcome
foo.allow_phi!('me', 'reason')
foo.association(:bar).reader.phi_allowed? # => true
foo.bar.phi_allowed? # => true
foo.association(:bar).reader.phi_allowed? # => true
```

We should update `allow_phi!` to proactively iterate over PHI extensions and _call_ allow PHI on them.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the allow_phi! implementation and trace how PHI extensions are registered and currently enabled when association methods are called. Reproduce the issue with the Foo, Bar, and Baz example; done means allow_phi! immediately makes the association reader report phi_allowed? as true, before accessing the association.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend, security
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.