Class: Clickwrap::AuthorityVerifier
- Inherits:
-
Object
- Object
- Clickwrap::AuthorityVerifier
- Defined in:
- lib/clickwrap/authority.rb
Overview
One fail-closed path for presentation-time and capture-time authority checks. The represented-party adapter owns the authorization fact; Clickwrap only validates that an affirmative decision carries enough provenance to become meaningful evidence.
Class Method Summary collapse
Class Method Details
.verify!(policy:, actor:, represented_party:, tenant:, authentication_context:) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/clickwrap/authority.rb', line 132 def self.verify!(policy:, actor:, represented_party:, tenant:, authentication_context:) unless policy.permits_acting_for_party?(represented_party) raise AuthorityNotVerified, "Policy #{policy.key} does not permit an actor to act for " \ "#{represented_party.class.name}. Declare the represented-party type and a " \ "reviewed server-side authority rule." end rule = policy. adapter = Clickwrap.config.(rule.adapter_name) raw = if adapter adapter.verify( actor: actor, represented_party: represented_party, authority_rule: rule, tenant: tenant, authentication_context: authentication_context ) else Clickwrap.config.verify_actor_can_act_for_represented_party_with.call( actor: actor, represented_party: represented_party, policy: policy, tenant: tenant, authentication_context: authentication_context ) end decision = AuthorityDecision.from(raw) unless decision. raise AuthorityNotVerified, "The host authority check did not authorize this actor to act for the represented party." end missing = %i[source role verified_at].select { |attribute| decision.public_send(attribute).blank? } return decision if missing.empty? raise AuthorityNotVerified, "An authorized represented-party action must record #{missing.join(", ")}. Return " \ "those facts from `verify_actor_can_act_for_represented_party_with`." end |