Class: Safire::Protocols::UdapScopeCoverage Private
- Inherits:
-
Object
- Object
- Safire::Protocols::UdapScopeCoverage
- Defined in:
- lib/safire/protocols/udap_scope_coverage.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Evaluates warning-only coverage of requested non-wildcard SMART FHIR scopes
against exhaustive UDAP scopes_supported metadata.
This collaborator deliberately does not authorize requests or decide hard failures. Exact wildcard-advertisement policy remains with Udap; this class only identifies non-wildcard scopes that cannot be locally proven to be covered for diagnostic purposes.
Class Method Summary collapse
Instance Method Summary collapse
- #advertised_exactly?(scope) ⇒ Boolean private
-
#initialize(advertised_scopes) ⇒ UdapScopeCoverage
constructor
private
A new instance of UdapScopeCoverage.
-
#uncovered_non_wildcards_for_warning(requested_scopes) ⇒ Array<String>
private
Returns requested non-wildcard scopes not exactly advertised or covered by recognized SMART FHIR resource scopes.
Constructor Details
#initialize(advertised_scopes) ⇒ UdapScopeCoverage
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of UdapScopeCoverage.
30 31 32 33 34 35 36 37 38 |
# File 'lib/safire/protocols/udap_scope_coverage.rb', line 30 def initialize(advertised_scopes) unless advertised_scopes.is_a?(Array) && advertised_scopes.all?(String) raise ArgumentError, 'advertised_scopes must be an array of strings' end @advertised_scopes = immutable_strings(advertised_scopes) @parsed_advertised_scopes = @advertised_scopes.filter_map { |scope| parse_scope(scope) }.freeze freeze end |
Class Method Details
.requested_wildcard?(scope) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/safire/protocols/udap_scope_coverage.rb', line 26 def self.requested_wildcard?(scope) scope.is_a?(String) && scope.include?('*') end |
Instance Method Details
#advertised_exactly?(scope) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'lib/safire/protocols/udap_scope_coverage.rb', line 40 def advertised_exactly?(scope) @advertised_scopes.include?(scope) end |
#uncovered_non_wildcards_for_warning(requested_scopes) ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns requested non-wildcard scopes not exactly advertised or covered by recognized SMART FHIR resource scopes. Compatible advertised entries may contribute a union of permissions for warning suppression only.
50 51 52 53 54 55 56 57 58 |
# File 'lib/safire/protocols/udap_scope_coverage.rb', line 50 def uncovered_non_wildcards_for_warning(requested_scopes) validate_requested_scopes!(requested_scopes) unique_scopes = requested_scopes.uniq if unique_scopes.any? { |scope| self.class.requested_wildcard?(scope) } raise ArgumentError, 'requested_scopes must not contain wildcard scopes' end unique_scopes.reject { |scope| advertised_exactly?(scope) || covered_fhir_scope?(scope) } end |