-
Notifications
You must be signed in to change notification settings - Fork 20
Description
The pain of #61 highlights that this regex is cumbersome to maintain. In referrals, we have an entry that looks like this:
configuration.allowlist_regexp = %r{\A/(referrals\/api\/contacts|referrals\/api\/referrals|assets|client|referrals\/api\/docs|referrals\/proof_of_life|referrals\/resque|referrals\/teaspoon)}It turns out that there was an overly permissive entry in there which essentially white listed all of the referrals API - not desirable and tests are being back filled.
I'd like to add something that's a bit easier to read/maintain. I spent some time trying to replace the middleware by creating a Rails custom constraint. Constraints have a handle on the request, but not on the response and so I ran into trouble when trying to replicate these lines:
stitches/lib/stitches/api_key.rb
Lines 44 to 45 in 80231b3
| env[@configuration.env_var_to_hold_api_client_primary_key] = client.id | |
| env[@configuration.env_var_to_hold_api_client] = client |
Is there a) still a need for these lines, and b) a way to move them out of the middleware? Or maybe some third way to make it more obvious in routes.rb what does/does not require the api_key? A less desirable option would be to add a before_filter in the controllers but I'm guessing that choice was avoided on purpose?