Skip to content

Fix vouch verification authorization (STI policy misroute)#274

Open
leowilkin wants to merge 1 commit into
mainfrom
fix/vouch-verification-policy-resolution
Open

Fix vouch verification authorization (STI policy misroute)#274
leowilkin wants to merge 1 commit into
mainfrom
fix/vouch-verification-policy-resolution

Conversation

@leowilkin

Copy link
Copy Markdown
Member

Problem

Creating a vouch verification returns "you don't seem to be authorized to do that?" for everyone — including super admins. Sentry confirms the failure:

not allowed to VerificationPolicy#create? Verification::VouchVerification (Pundit::NotAuthorizedError)

Root cause

Verification is an STI base class and Verification::VouchVerification is a subclass. When Backend::IdentitiesController#new_vouch / #create_vouch call:

authorize Verification::VouchVerification, :create?

Pundit resolves the policy via find_class_name, which calls subject.model_name. For an STI subclass, model_name returns the base class name ("Verification"), so Pundit builds VerificationPolicy and never reaches Verification::VouchVerificationPolicy.

VerificationPolicy doesn't define create?, so it falls through to ApplicationPolicy#create? = false → denied for all users. The intended gate, VouchVerificationPolicy#create? = user.super_admin?, never runs.

Fix

Pass policy_class: explicitly at both call sites so STI model_name resolution can't misroute it:

authorize Verification::VouchVerification, :create?, policy_class: Verification::VouchVerificationPolicy

create? is the only method where the subclass policy diverges from VerificationPolicy, and it's only ever invoked with the class form in these two actions, so this is the minimal correct change.

Testing

  • Super admin can open /backend/identities/:id/new_vouch and create a vouch
  • Non-super-admin (e.g. manual document verifier) is still denied

Verification is an STI base class, so Pundit's class-based authorize
resolves Verification::VouchVerification via model_name -> the base
class name ("Verification"), landing on VerificationPolicy instead of
Verification::VouchVerificationPolicy. VerificationPolicy never defines
create?, so it falls through to ApplicationPolicy#create? = false and
denies everyone, including super admins.

Pass policy_class explicitly on both new_vouch and create_vouch so the
super_admin gate in VouchVerificationPolicy#create? actually runs.
@leowilkin leowilkin force-pushed the fix/vouch-verification-policy-resolution branch from 2edd0c4 to 5889dfe Compare June 18, 2026 11:35
@leowilkin leowilkin requested a review from 24c02 June 18, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant